Migration problem

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:inconst_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:inconstantize’
/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:inmigration_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:ininject’
/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:ininject’
/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:inmigrate’
/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:inmigrate’
/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:inexecute’
/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:inexecute’
/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:insynchronize’
/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:intop_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:intop_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:intop_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:instandard_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:inload’
/usr/bin/rake:16

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

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 M. [email protected]

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 M. [email protected]

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.

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 M. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs