Hi. When I read Dave and Davids excellent book "Agile Web Development with Rails" the first time, I was particularly impressed with the following statement: 1.day.from_now It was used in a test class to set the date of tomorrow dynamically. Since it was enclosed in in ERb tags, I assumed this was a normal ruby statement, but when I tried it in my irb, i get the following error: irb(main):007:0> 1.day.from_now NoMethodError: undefined method `day'' for 1:Fixnum from (irb):7 irb(main):008:0> I would be abliged if someone could explain to me how this works in ERb and not in standard ruby? Have I missed something fundamental here? Best regards, J?rn ?lmheim www: http://www.olmheim.com blog: http://blog.olmheim.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060331/ab665050/attachment.html
Its an extension f the Time class http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Numeric/ Time.html So, its not ruby, its rails... On Friday, March 31, 2006, at 1:48 PM, Jørn Ølmheim wrote:>Hi. > >When I read Dave and Davids excellent book "Agile Web Development with >Rails" the first time, I was particularly impressed with the following >statement: >1.day.from_now > >It was used in a test class to set the date of tomorrow dynamically. Since >it was enclosed in in ERb tags, I assumed this was a normal ruby statement, >but when I tried it in my irb, i get the following error: >irb(main):007:0> 1.day.from_now >NoMethodError: undefined method `day'' for 1:Fixnum > from (irb):7 >irb(main):008:0> > >I would be abliged if someone could explain to me how this works in ERb and >not in standard ruby? Have I missed something fundamental here? > >Best regards, >J?rn ?lmheim >www: http://www.olmheim.com >blog: http://blog.olmheim.com > > >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/rails >Mikkel Bruun www.strongside.dk - Football Portal(DK) ting.minline.dk - Buy Old Stuff!(DK) -- Posted with http://DevLists.com. Sign up and save your time!
Indeed. You need to use script/console instead of a plain ruby shell. On 31 Mar 2006 12:02:10 -0000, Mikkel Bruun < devlists-rubyonrails@devlists.com> wrote:> > Its an extension f the Time class > > http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Numeric/ > Time.html > > So, its not ruby, its rails... > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060331/48b310ba/attachment.html
On 31-mrt-2006, at 13:48, J?rn ?lmheim wrote:> Hi. > > When I read Dave and Davids excellent book "Agile Web Development > with Rails" the first time, I was particularly impressed with the > following statement: > 1.day.from_now > > It was used in a test class to set the date of tomorrow > dynamically. Since it was enclosed in in ERb tags, I assumed this > was a normal ruby statement, but when I tried it in my irb, i get > the following error: > irb(main):007:0> 1.day.from_now > NoMethodError: undefined method `day'' for 1:Fixnum > from (irb):7 > irb(main):008:0> > > I would be abliged if someone could explain to me how this works in > ERb and not in standard ruby? Have I missed something fundamental > here? >days_from_now etc. is a part of ActiveSupport
Heh, in a thread last week about Rails driving development of Ruby, somebody asked how long it would be til someone mistook Rails'' core-extensions for Ruby :) Jeff Julian ''Julik'' Tarkhanov wrote:> On 31-mrt-2006, at 13:48, J?rn ?lmheim wrote: > >> the following error: >> irb(main):007:0> 1.day.from_now >> NoMethodError: undefined method `day'' for 1:Fixnum >> from (irb):7 >> irb(main):008:0> >> >> I would be abliged if someone could explain to me how this works in >> ERb and not in standard ruby? Have I missed something fundamental >> here? >> > > days_from_now etc. is a part of ActiveSupport-- Posted via http://www.ruby-forum.com/.