没有找到Rails路由

时间:2014-03-16 19:27:05

标签: ruby-on-rails ruby-on-rails-4

我的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 %>

1 个答案:

答案 0 :(得分:2)

尝试_path选项中没有as后缀):

get '/roomidex_requests/:id/accept' => 'roomidex_requests#accept', :as => :accept_roomidex_requests

可能你应该将http动词更改为post