Re: [Rails] Error : can't dup NilClass, in Heroku
Hi,
This is:
" str , can't dup NilClass, ["C:/Ruby192/lib/ruby/1.9.1/date/format.rb:1031:in `dup'", "C:/Ruby192/lib/ruby/1.9.1/date/format.rb:1031:in `_parse'", "C:/Ruby192/lib/ruby/1.9.1/time.rb:261:in `parse'", "g.rb:29:in `dateTimeFromString'", "g.rb:40:in `initialize'", "g.rb:45:in `new'", "g.rb:45:in `<main>'"]"
I reproduced the error and I detected that when the parameter that was sent to the function is nil. But I keep trying because the field is database and should not be null according to business rules.
I was confused because I found forums where suggested using the statement ' unloadable ' but was inconclusive.
If you have another point of view will be welcome,
thanks
2012/5/21 Jeremy Walker <jez.walker@gmail.com>
--Hi,
The application is deployed on Heroku, is based on Ruby 3.2.1 and Rails 1.9.2. Sometimes a function of my props starts throwing this error " StringUtils:dateTimeFromString, str , can't dup NilClass" and I don't understand the cause. it's my function:
require 'time'
module StringUtils
DATE_FORMAT_YYYY_MM_DD='%Y-%m-%d'
DATE_FORMAT_HH_MM_SS='%H:%M:%S'
DATE_FORMAT_YYYY_MM_DD_HH_MM_SS='%Y-%m-%d %H:%M:%S'
DATE_FORMAT_YYYY_MM_DD_T_HH_MM_SS='%Y-%m-%dT%H:%M:%S'
DATE_FORMAT_YYYYMMDDHHMMSS='%Y%m%d%H%M%S'
DATE_FORMAT_DAY_OF_WEEK="%A"
def stringFormatDate(strDate,format)
if strDate!=nil
begin
return Time.parse(strDate).strftime(format)
rescue
Rails.logger.error("StringUtils:stringFormatDate, str #{strDate}, #{$!}")
end
end
return strDate
end
def dateTimeFromString(strDate)
begin
return Time.parse(strDate)
rescue
Rails.logger.error("StringUtils:dateTimeFromString, str #{strDate}, #{$!}")
return nil
end
end
endCan you provide a stack trace from your logs please.--
I hope your comments, Thanks
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
--
Johan Rincón
Ing. en Informática
UNET
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home