我想request.method应该返回一个符号一样:get,:put等等?但是在控制器动作中,我得到的GET是一个字符串!
难道我做错了什么?
在routes.rb:
resources :posts
member do
get 'some_action'
end
end
Run Code Online (Sandbox Code Playgroud)
在.erb视图中:
<%= link_to "Some Action",some_action_post_path %>
Run Code Online (Sandbox Code Playgroud)
在PostsController:
def some_action
p request.method # => "GET"
p request.method.class.name # => "String"
if request.method == :get
#does not get called
end
end
Run Code Online (Sandbox Code Playgroud)
PS.我在Ruby 1.8.7 p330上使用Rails 3.0.3