我的Rails路由不起作用,我在加载时收到此错误:
undefined method `accept_roomidex_requests_path' for #<#<Class:0x00000103394050>:0x000001033ac920>
以下是我的(相关)文件内容:
config.rb
get '/roomidex_requests/:id/accept' => 'roomidex_requests#accept', :as => :accept_roomidex_requests_path
roomidex_requests_controller.rb
def accept
# code to do stuff
end
some_view.rb
<%= link_to "Accept",
accept_roomidex_requests_path(:id),
:method => :post,
:remote => true %>
答案 0 :(得分:2)
尝试_path
选项中没有as
后缀):
get '/roomidex_requests/:id/accept' => 'roomidex_requests#accept', :as => :accept_roomidex_requests
可能你应该将http动词更改为post
。