这就是我在本地服务器上所说的:
Started GET "/hunt/one" for 127.0.0.1 at 2015-04-14 23:54:47 -0700
ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
Processing by HuntController#one as HTML
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY "users"."id" ASC LIMIT 1
Rendered hunt/one.html.erb (281.8ms)
Completed 500 Internal Server Error in 406ms
ActionView::Template::Error (No route matches {:action=>"update_clue1", :controller=>"clue", :id=>nil} missing required keys: [:id]):
在我的控制器中
def update_clue1
@clue = Clue.find(1)
@clue.update_attributes(clue1: true)
redirect_to "/home/clues"
end
在我的路线
resources :clue do
member do
get :update_clue1
put :update_clue1
end
end
在我看来
<%= link_to "See next clue", update_clue1_clue_path(@clue), method: :put, class: "btn btn-default" %>
感谢您的帮助!
修改
New Error /Users/coleschiffer/Code/rp/protected-beyond-7706/app/controllers/hunt_controller.rb:14: class/module name must be CONSTANT
这是狩猎控制器
def update_clue1
@clue = Clue.find(1)
@clue.update_attributes(clue1: true)
redirect_to "/home/clues "
end