Hi all, I have an error while running the migration. The following is the problem. I have a table called sequences. Am adding a column called ''seq_type'' in migration Version 79. and after adding am also inserting a row in the table, then its throwing an error called "undefined method seq_type= for <Sequence:0x4cab0f8>" This is my code. def self.up add_column :sequences, :seq_type, :integer, :limit => 1 Sequence.create(:user_id => 1, :seq_type => 2) end Column is getting added, but the row is not getting created. when I run the migration again by commenting the first line , then its working properly. Why it is not working for the first time? I also tried to put the row creation in the next migration, even then its failing. What could be the reason?? It it not detecting the column? If not what to do?? Kindly please help me.. -- 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 -~----------~----~----~----~------~----~------~--~---
I don''t think that ActiveRecord, of which your Sequence is a subclass, knows yet about the new column. Anyway, it''s a good idea to use models in migrations as little as possible so that changes in models don''t break older migrations. I''d recommend using SQL to add the data if you want to add it in this migration. If the data is seed data, i.e., it''s basic data that needs to be there for your application to run, I''d recommend using one of the many data seeding techniques that have been discussed/announced in the group before. Regards, Craig --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 28 Aug 2008, at 13:33, Craig Demyanovich wrote:> I don''t think that ActiveRecord, of which your Sequence is a > subclass, knows yet about the new column.If that''s the case, Sequence.reset_column_information should sort things out. Fred> Anyway, it''s a good idea to use models in migrations as little as > possible so that changes in models don''t break older migrations. I''d > recommend using SQL to add the data if you want to add it in this > migration. If the data is seed data, i.e., it''s basic data that > needs to be there for your application to run, I''d recommend using > one of the many data seeding techniques that have been discussed/ > announced in the group before. > > Regards, > Craig > > >--~--~---------~--~----~------------~-------~--~----~ 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, Thanks a lot.. I used Sequence.reset_column_information and its working perfectly.. Cheers.. Naga Harish Kanegolla Frederick Cheung wrote:> On 28 Aug 2008, at 13:33, Craig Demyanovich wrote: > >> I don''t think that ActiveRecord, of which your Sequence is a >> subclass, knows yet about the new column. > If that''s the case, Sequence.reset_column_information should sort > things out. > > Fred-- 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 -~----------~----~----~----~------~----~------~--~---