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* end 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 21 May 2012, at 17:07, johan rincon <nahoj28nahoj28-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> > > On 21 May 2012, at 17:07, johan rincon <nahoj28nahoj28-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > 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* > end > > > Can 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Maybe Matching Threads
- Asking help about drawing and saving candle chart automatically....
- cleanup and Makevars
- How to seperate date and time into different columns?
- Can't get xapian-core 1.05 to build under windows xp
- patch-Add standard ExpandDecider subclass to restrict to terms with a particular prefix