I notice that when I generate a migration alone using the migration generator, the name of the resulting file is something like "db/ migrate/001_members.rb" and that file contains a class named "Members". However, if instead I generate a model and let that process create the migration for me, the name of the resulting file is something like "db/migrate/001_create_members.rb" and that file contains a class named "CreateMembers". Information that I''ve been able to find on the web (e.g., http://www.railsforum.com/viewtopic.php?id=1011) seems to imply (although it doesn''t specifically say) that the actual base names of the file doesn''t really matter, it''s only the pre- appended number that''s important. I would think that the base name of the file would have to identify the table; otherwise, how would rake know what table is being modified in subsequent migrations? Anyway, I know that I must be missing something. Can someone please clarify the confusion for me? Thanks for any input. ... doug --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
The class name of the migration must match the file name (without the leading number). The leading number is used for the order (try changing the name of a migration and see what happens). 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 -~----------~----~----~----~------~----~------~--~---
doug wrote:> I notice that when I generate a migration alone using the migration > generator, the name of the resulting file is something like "db/ > migrate/001_members.rb" and that file contains a class named > "Members". However, if instead I generate a model and let that > process create the migration for me, the name of the resulting file is > something like "db/migrate/001_create_members.rb" and that file > contains a class named "CreateMembers".When you create a model (maybe with attributes) the generator figures there will be a table behind the model that needs to be created. So it generates some ruby code in a class it names Create<ModelName> and a file named "xxx_create_<modelName>". This convention allows Rails to know what migrations are associated with what Models (and other things). When you want just a migration, the generator doesn''t know what your migration is going (perhaps you''re adding a column? Data? Changing something?). If you were too add columns, the convention is to uses a name like add_<column_names>, but that''s just for you to help remember. The generator uses that name to come up with a class name for the migration, a file name, and then uses the data in the table schema_info to come up with the next sequence number. The rest is up to you. Said another way, migrations don''t use naming conventions in order to execute, they just use the serial number to know which version of the schema to create, and in what order. -- 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 get it! Thanks, guys. ... doug --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---