无法将正确的参数传递给RoR中的操作

时间:2012-08-05 08:52:23

标签: ruby-on-rails-3

Rails 3.2.2

即使我转到页面ArgumentError missing :action

,此代码也会引发异常/my_controller/some_action1
#routes
namespace :my_controller do 
    get 'some_action1'
    get 'some_action2/:some_param1'

  end

#Controller
class MyController < ApplicationController
 def some_action1
 end

 def some_action2
  #handling the ajax request
  respond_to do |format|
     format.js
  end
 end

end

#View /my_controller/some_action1.html.haml
link_to "my_link", {:controller => :my_controller, :action => :some_action2,
                             :some_param1=>123}, :remote=>true, :id=>"unique_id123"

你的想法?

1 个答案:

答案 0 :(得分:2)

尝试用以下代码替换您的路线:

match '/my_controller/some_action1' => "my_controller#some_action1", :via => :get
match '/my_controller/some_action2/:some_param1' => "my_controller#some_action2", :via => :get