我想要下一件事:单击按钮时,我想打印params[:id]
.welcome controller
这是我的java脚本代码:
$(".btn_skip").click(function() {
$.ajax({
url: '/welcome',
type: 'PUT',
data: {show_msg: $("#mycheckbox").is(":checked")}
});
});
这是我的welcome_controller.rb
:
class WelcomeController < ApplicationController
def update
@user = User.find(params[:id])
puts params[:id]
end
end
当我跑:rails s
并按下按钮(btn_skip)时,我得到:
Started PUT "/welcome" for 127.0.0.1 at 2013-02-05 12:18:26 +0200
ActionController::RoutingError (No route matches [PUT] "/welcome"):
路线.rb:
resources :welcome
rake routes
:
welcome_index GET /welcome(.:format) welcome#index
POST /welcome(.:format) welcome#create
new_welcome GET /welcome/new(.:format) welcome#new
edit_welcome GET /welcome/:id/edit(.:format) welcome#edit
welcome GET /welcome/:id(.:format) welcome#show
PUT /welcome/:id(.:format) welcome#update
DELETE /welcome/:id(.:format) welcome#destroy
也许,我应该传递 idurl: '/welcome'
吗?
如果是这样,我怎样才能得到身份证?也许是:url:'/welcome/#{:id}'?
任何帮助表示赞赏!