I use the following steps to create a model and migrate. However when it comes running ''rake db:migrate'' it gave me the following errors. I suspect it is due to the fact that I was trying to put everything about blog in its own folder. Is this possible with migration or is there a different way of putting topics into their own folder. Here are the steps that I did. 1) ruby script/generate model ''blog/post'' 2) rake db:migrate It tried to create a constant ''CreateBlogPosts'' which I don''t think its suppose to. Anyone who can help or suggest something would be greatly appreciated. If I can''t do it this way I''ll go back to using ''script/generate model Post''. Thanks in advance The error it threw are: (in /home/naruto/sites/geneva) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate rake aborted! uninitialized constant CreateBlogPosts /home/naruto/sites/geneva/vendor/rails/activerecord/lib/../../ activesupport/lib/active_support/dependencies.rb:266:in `load_missing_constant'' /home/naruto/sites/geneva/vendor/rails/activerecord/lib/../../ activesupport/lib/active_support/dependencies.rb:452:in `const_missing'' /home/naruto/sites/geneva/vendor/rails/activerecord/lib/../../ activesupport/lib/active_support/dependencies.rb:464:in `const_missing'' /home/naruto/sites/geneva/vendor/rails/activerecord/lib/../../ activesupport/lib/active_support/inflector.rb:250:in `constantize'' /home/naruto/sites/geneva/vendor/rails/activerecord/lib/../../ activesupport/lib/active_support/core_ext/string/inflections.rb:148:in `constantize'' /home/naruto/sites/geneva/vendor/rails/activerecord/lib/active_record/ migration.rb:366:in `migration_class'' /home/naruto/sites/geneva/vendor/rails/activerecord/lib/active_record/ migration.rb:346:in `migration_classes'' /home/naruto/sites/geneva/vendor/rails/activerecord/lib/active_record/ connection_adapters/mysql_adapter.rb:248:in `inject'' /home/naruto/sites/geneva/vendor/rails/activerecord/lib/active_record/ migration.rb:342:in `each'' /home/naruto/sites/geneva/vendor/rails/activerecord/lib/active_record/ migration.rb:342:in `inject'' /home/naruto/sites/geneva/vendor/rails/activerecord/lib/active_record/ migration.rb:342:in `migration_classes'' /home/naruto/sites/geneva/vendor/rails/activerecord/lib/active_record/ migration.rb:330:in `migrate'' /home/naruto/sites/geneva/vendor/rails/activerecord/lib/active_record/ migration.rb:297:in `up'' /home/naruto/sites/geneva/vendor/rails/activerecord/lib/active_record/ migration.rb:288:in `migrate'' /home/naruto/sites/geneva/vendor/rails/railties/lib/tasks/ databases.rake:4 /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `call'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `each'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in `invoke'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `synchronize'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `each'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in `standard_exception_handling'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1733:in `top_level'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1711:in `run'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in `standard_exception_handling'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1708:in `run'' /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7 /usr/bin/rake:16:in `load'' /usr/bin/rake:16 --~--~---------~--~----~------------~-------~--~----~ 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 got a similar error once, when trying to run migrate on a file where the classname didn''t match the filename so if you have a migration file like 001_create_blog_posts.rb your class definition in the file must be: class CreateBlogPosts < ActiveRecord::Migration nothing else is allowed, camelcase must match underscores -- 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 -~----------~----~----~----~------~----~------~--~---
thanks this worked. However, should migration have created the file properly like you mention instead of class CreatePosts < ActiveRecord::Migration? On Dec 3, 1:08 pm, Thorsten Mueller <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> i got a similar error once, when trying to run migrate on a file where > the classname didn''t match the filename > > so if you have a migration file like > > 001_create_blog_posts.rb > > your class definition in the file must be: > > class CreateBlogPosts < ActiveRecord::Migration > > nothing else is allowed, camelcase must match underscores > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
winslowly wrote:> thanks this worked. However, should migration have created the file > properly like you mention instead of class CreatePosts < > ActiveRecord::Migration? > > On Dec 3, 1:08 pm, Thorsten Mueller <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>only with that syntax: ruby script/generate model ''blog_posts'' your version: ruby script/generate model ''blog/post'' isn''t clear to me, maybe to generate a model in a subdirectory? i would expect it to generate an error, but sometimes rails is a bit too smart and makes ''something'' out of the input. -- 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 -~----------~----~----~----~------~----~------~--~---
yeah, I was trying to put all models belonging to blog inside its own subdirectory. Again thanks for the help. On Dec 3, 1:20 pm, Thorsten Mueller <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> winslowly wrote: > > thanks this worked. However, should migration have created the file > > properly like you mention instead of class CreatePosts < > > ActiveRecord::Migration? > > > On Dec 3, 1:08 pm, Thorsten Mueller <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > only with that syntax: > > ruby script/generate model ''blog_posts'' > > your version: > > ruby script/generate model ''blog/post'' > > isn''t clear to me, maybe to generate a model in a subdirectory? i would > expect it to generate an error, but sometimes rails is a bit too smart > and makes ''something'' out of the input. > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---