Hi When I use a fixture yml file to load setup data into my database my created_at fields are always being set to ''0000-00-00 00:00:00'' I have even tried injecting sql AND ruby code into the data field of the yml to no avail. Granted I could just change the default value of the field in the DB to be "now" (Or the Db specific function) but since I''m letting migrations take care of everything I figure it should .. well.. take care of everything. Ex yml. entry_1: name: foo value: bar created_at: now() entry_2: name: bin value: baz created_at: Time.now entry_3: name: woo value: hah Notice with entry 3 there is no created_at field but I get the same results for created_at for all three entries. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
See below. Quoting Jean Nibee <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > Hi > > When I use a fixture yml file to load setup data into my database my > created_at fields are always being set to ''0000-00-00 00:00:00'' > > I have even tried injecting sql AND ruby code into the data field of the > yml to no avail. > > Granted I could just change the default value of the field in the DB to > be "now" (Or the Db specific function) but since I''m letting migrations > take care of everything I figure it should .. well.. take care of > everything. > > Ex yml. > > entry_1: > name: foo > value: bar > created_at: now()Close. Try this: created_at: <%= Time.now %> Actually, this should be the default in Rails 2.x. And you can do things like this: created_at: <%= 1.hour.ago.to_s(:db) %> HTH, Jeffrey --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, On Wed, Sep 24, 2008 at 8:21 PM, Jean Nibee <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> When I use a fixture yml file to load setup data into my database my > created_at fields are always being set to ''0000-00-00 00:00:00''The fixtures code in 2.0+ should set your timestamped columns to Time.now automatically if they''re not explicitly specified: http://github.com/rails/rails/tree/master/activerecord/lib/active_record/fixtures.rb#L581 Can you try and boil this down to a small, repeatable testcase? ~ j. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---