I defines a table and one of its column type is Time. I use ruby Time class to assign the value to this column, but it always generate Sat Jan 01 2000 time. Is the format different with the database and ruby class? I use MySql database in Linux. -- 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 -~----------~----~----~----~------~----~------~--~---
Are you using Time.now to assign the time? On Jan 21, 7:44 pm, Zhao Yi <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I defines a table and one of its column type is Time. I use ruby Time > class to assign the value to this column, but it always generate Sat Jan > 01 2000 time. Is the format different with the database and ruby class? > I use MySql database in Linux. > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Bobnation wrote:> Are you using Time.now to assign the time?Yes, I use Time.now. -- 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 -~----------~----~----~----~------~----~------~--~---
Can you post your schema.rb? On Jan 21, 10:45 pm, Zhao Yi <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Bobnation wrote: > > Are you using Time.now to assign the time? > > Yes, I use Time.now. > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Bobnation wrote:> Can you post your schema.rb?This is schema file: class CreateHistories < ActiveRecord::Migration def self.up create_table :histories do |t| t.string :user_name,:null=>false t.string :project_name,:null=>false t.string :view t.string :task t.date :date t.time :time t.string :log t.timestamps end end def self.down drop_table :histories end end -- 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 -~----------~----~----~----~------~----~------~--~---
Do created_at and updated_at (via t.timestamps) get set properly? I think you could try using t.timestamp (not plural) instead of t.time. Or, instead of using "sexy migrations", you could try doing it the old way: t.column :my_time_column, :datetime Hope this helps, Jason Arora On Jan 21, 11:01 pm, Zhao Yi <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Bobnation wrote: > > Can you post your schema.rb? > > This is schema file: > > class CreateHistories < ActiveRecord::Migration > def self.up > create_table :histories do |t| > t.string :user_name,:null=>false > t.string :project_name,:null=>false > t.string :view > t.string :task > t.date :date > t.time :time > t.string :log > > t.timestamps > end > end > > def self.down > drop_table :histories > end > end > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
jasoo24 wrote:> Do created_at and updated_at (via t.timestamps) get set properly? I > think you could try using t.timestamp (not plural) instead of t.time. > > Or, instead of using "sexy migrations", you could try doing it the old > way: > t.column :my_time_column, :datetime > > Hope this helps, > Jason AroraHow can I migrate this schema without breaking this table? I have tried to run "rake db:migrate" but it doesn''t work. -- 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 -~----------~----~----~----~------~----~------~--~---