的routes.rb
match 'mybookings/:token' => 'mybookings#test', :as => 'bookit'
resources :mybookings
rails routes显示:
bookit /app/mybookings/:token(.:format) mybookings#test
然后我使用帮手:
=link_to "by clicking here", bookit_url(@client.token)
结果是
ActionView::Template::Error
Error
undefined method `bookit_url' for #<#<Class:0x007fd2c1ca3488>:0x007fd2c1f96960>
那个助手有什么问题?
答案 0 :(得分:1)
你的代码在我的Rails 3.2中运行良好
这是关键代码:
# in routes.rb
match 'mybookings/:token' => 'mybookings#test', :as => 'bookit'
# in controller:
class MybookingsController
def test
render :text => 'this is bookit action'
end
end
# in your erb or haml file:
link_to "by clicking here", bookit_url('this is the token string')