Forum: Ruby on Rails rake db:migrate "no such option: controller action" problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jordan E. (Guest)
on 2007-03-02 21:57
(Received via mailing list)
Hi,
I've getting weirdness when running rake db:migrate. This rails
project was originally created on windows. I don't know if that makes
a difference?

This is the output from a --trace.

** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
no such option: controller action
/usr/lib/ruby/1.8/fileutils.rb:1424:in `fu_check_options'
/usr/lib/ruby/1.8/fileutils.rb:535:in `remove'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb:816:in `remove'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/option_merger.rb:14:in
`send'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/option_merger.rb:14:in
`method_missing'
/mnt/iriver/projects/routes/config/../config/routes.rb:27
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/core_ext/object/misc.rb:28:in
`with_options'
/mnt/iriver/projects/routes/config/../config/routes.rb:24
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/routing.rb:1139:in
`draw'
/mnt/iriver/projects/routes/config/../config/routes.rb:1
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:488:in
`load'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:488:in
`load'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:342:in
`new_constants_in'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:488:in
`load'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/routing.rb:1165:in
`load_routes!'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/action_controller/routing.rb:1157:in
`reload'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/initializer.rb:287:in
`initialize_routing'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/initializer.rb:111:in
`process'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/initializer.rb:43:in `send'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/initializer.rb:43:in `run'
/mnt/iriver/projects/routes/config/../config/environment.rb:13
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/tasks/misc.rake:3
/usr/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb:399:in `call'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb:399:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb:399:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb:399:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb:369:in `invoke'
/usr/lib/ruby/1.8/thread.rb:135:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb:362:in `invoke'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb:376:in
`invoke_prerequisites'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb:1021:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb:1021:in `send'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb:1021:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb:375:in
`invoke_prerequisites'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb:368:in `invoke'
/usr/lib/ruby/1.8/thread.rb:135:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb:362:in `invoke'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb:1935:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb:1935:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.2/lib/rake.rb:1935:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.7.2/bin/rake:7
/usr/bin/rake:16:in `load'
/usr/bin/rake:16

Any ideas?

Thanks,
Jord
Conrad T. (Guest)
on 2007-03-03 00:01
(Received via mailing list)
Hi, let's see the file(s) that you're trying to migrate (i.e.
${PROJECT_ROOT}/db/migrate )

Thanks,

-Conrad
Jordan E. (Guest)
on 2007-03-03 12:33
(Received via mailing list)
> Hi, let's see the file(s) that you're trying to migrate (i.e.
> ${PROJECT_ROOT}/db/migrate )

Here they are. I've also tried removing these from the directory with
the same result. So, I don't think the migrations themselves are to
blame.

class CreateCategories < ActiveRecord::Migration
  def self.up
    create_table :categories do |t|
      t.column :name, :string
      t.column :parent_id, :integer, :default => 0
    end

    # create some defaults
    Category.create :name => 'Fruit and Veg'
    Category.create :name => 'Bakery'

    Category.create :name => 'Apples', :parent_id => 1
    Category.create :name => 'Bananas', :parent_id => 1
    Category.create :name => 'Potatoes', :parent_id => 1

    Category.create :name => 'Cakes', :parent_id => 2
    Category.create :name => 'Bread', :parent_id => 2
    Category.create :name => 'Pastries', :parent_id => 2

  end

  def self.down
    drop_table :categories
  end
end

class CreateProducts < ActiveRecord::Migration
  def self.up
    create_table :products do |t|
      t.column :name, :string
    end
  end

  def self.down
    drop_table :products
  end
end

class AddProductCategoryJoinTable < ActiveRecord::Migration
  def self.up
    create_table :categories_products, :id => false do |t|
      t.column :product_id, :integer
      t.column :category_id, :integer
    end
  end

  def self.down
    drop_table :categories_products
  end
end

class AddProducts < ActiveRecord::Migration
  def self.up
    Product.create :name => 'Cherry Bakewell', :category_ids => [6]
  end

  def self.down
  end
end

I've now been able to test this on another windows box, and the same
happens. Not sure what's going on?!

Cheers,
Jord
Jordan E. (Guest)
on 2007-03-05 10:45
(Received via mailing list)
Anyone? I'm not sure what's happening here at all.
Conrad T. (Guest)
on 2007-03-05 11:35
(Received via mailing list)
Hi, thanks for getting back with some information.  Anyway, it seems
to be an error with the last migration, AddProduct, because the
products table doesn't have a ':category_ids' field.  Shouldn't this
be called ':category_id' ?  Just a thought.  Finally, I would
recommend thinking about what you would like to do and execute the
required steps in an incremental fashion.

For example, I performed the following actions so that you can see the
steps:

a) rails test2 <ENTER>

b) cd test2 <ENTER>

c) script/generate model category <ENTER>

d) # edit the file appropriate migration file

e) rake db:migrate <ENTER>

f) script/generate model product <ENTER>

g) # edit the file appropriate migration file

h) rake db:migrate <ENTER>

i) script/generate migration add_product_join_table <ENTER>

j) # edit the file appropriate migration file

k) rake db:migrate <ENTER>

l) script/generate migration add_product <ENTER>

m) # edit the file appropriate migration file

n) rake db:migrate <ENTER>

If you have any questions, please let me know.

Good luck,

-Conrad

ps:  For additional information, please see AWDwRv2.
Jean-François Trân (Guest)
on 2007-03-05 15:28
(Received via mailing list)
Hi Jordan,

> Anyone? I'm not sure what's happening here at all.

Can we have a look at your config/routes.rb ?

  -- Jean-François.

--
Ruby ( http://www.rubyfrance.org ) on Rails ( http://www.railsfrance.org
)
Jordan E. (Guest)
on 2007-03-05 16:33
(Received via mailing list)
> Can we have a look at your config/routes.rb ?

You sure can. Sorry for the formatting.

ActionController::Routing::Routes.draw do |map|

  # map the route to the home page
  map.home '/', :controller => 'catalog', :action => 'home'

  # admin mappings
  map.admin             '/admin',                       :controller =>
'admin/base',    :action => 'dashboard'
  map.orders_admin      '/admin/orders/:action/:id',    :controller =>
'admin/orders'
  map.products_admin    '/admin/products/:action/:id',  :controller =>
'admin/products'

  # help page (mostly static stuff)
  map.help '/help', :controller => 'pages', :action => 'help'

  # account actions
  map.with_options :controller => 'account' do |account|
    account.signup      '/account/signup',              :action =>
'signup'
    account.login       '/login',                       :action =>
'login'
    account.logout      '/logout',                      :action =>
'logout'
    account.forgotten   '/account/forgotten',           :action =>
'forgotten'
    account.reset       '/account/reset/:reset_token',  :action =>
'reset',     :defaults => { :reset_token => nil }
  end

  # cart actions
  map.with_options :controller => 'cart' do |cart|
    cart.show       '/cart',            :action => 'show'
    cart.purchase   '/cart/:id/add',    :action => 'add'
    cart.remove     '/cart/:id/remove', :action => 'remove'
    cart.empty      '/cart/empty',      :action => 'empty'
  end

  # map checkout actions
  map.with_options :controller => 'checkout' do |checkout|
    checkout.delivery_address   '/checkout/delivery',   :action =>
'delivery_address'
    checkout.billing_address    '/checkout/invoice',    :action =>
'invoice_address'
    checkout.payment            '/checkout/payment',    :action =>
'payment'
    checkout.thanks             '/checkout/thanks',     :action =>
'thanks'
  end

  # map shop actions
  map.with_options :controller => 'catalog' do |catalog|
    catalog.product       '/product/:id',               :action =>
'show'
    catalog.product_zoom  '/product/:id/zoom/:pic_id',  :action =>
'zoom', :requirements => { :pic_id => /\d+/ }, :defaults => { :pic_id
=> 1 } #default to the first pic
    catalog.category      ':category',                  :action =>
'category'
    catalog.department    ':category/:department',      :action =>
'department'
  end

  # catchall route (raise status 404 here?)
  map.connect '*path' , :controller => 'pages' , :action =>
'unrecognized'
end
Jean-François Trân (Guest)
on 2007-03-05 17:47
(Received via mailing list)
Jordan :
> > Can we have a look at your config/routes.rb ?
>
> You sure can. Sorry for the formatting.
>
> ActionController::Routing::Routes.draw do |map|
[...]
>   # cart actions
>   map.with_options :controller => 'cart' do |cart|
>     cart.show       '/cart',            :action => 'show'
>     cart.purchase   '/cart/:id/add',    :action => 'add'

Line 27 is the one below, right ?

>     cart.remove     '/cart/:id/remove', :action => 'remove'
>     cart.empty      '/cart/empty',      :action => 'empty'
>   end

1/ Do a simple script/console to check if you've got the same
bug.

2/ try to uncomment the line :
     cart.remove     '/cart/:id/remove', :action => 'remove'

to check if it's responsible of the bug.

3/ you can also downgrade to rake 0.7.1 to see if the bug is
still there.

I don't really understand what's going on, but I suppose
it deals with the changes between Rake 0.7.1 to 0.7.2
rather than a migration problem.

   -- Jean-François.

--
Ruby ( http://www.rubyfrance.org ) on Rails ( http://www.railsfrance.org
)
Jordan E. (Guest)
on 2007-03-05 19:32
(Received via mailing list)
Hi Jean-François,

> 2/ try to uncomment the line :
>      cart.remove     '/cart/:id/remove', :action => 'remove'
>
> to check if it's responsible of the bug.

Yes, it was. After you mentioned the routes.rb file, I actually went
through the file and commented out each line to see if any was
responsible for this and found this problem. I've now renamed the
route:

cart.remove_item     '/cart/:id/remove', :action => 'remove'

Everything works now :)

Thanks very much for your help :)
Jord
This topic is locked and can not be replied to.