routes.rb
的routes.rb
match 'mybookings/:token' => 'mybookings#test', :as => 'bookit'
resources :mybookings
rails routes shows:
rails路线显示:
bookit /app/mybookings/:token(.:format) mybookings#test
Then I use a helper:
然后我用一个帮手:
=link_to "by clicking here", bookit_url(@client.token)
Which results in
结果如何
ActionView::Template::Error
Error
undefined method `bookit_url' for #<#<Class:0x007fd2c1ca3488>:0x007fd2c1f96960>
What's wrong with that helper?
那个助手有什么问题?
1 个解决方案
#1
1
your code works fine for me in Rails 3.2
你的代码在Rails 3.2中适合我
here are the key code:
这是关键代码:
# 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')
#1
1
your code works fine for me in Rails 3.2
你的代码在Rails 3.2中适合我
here are the key code:
这是关键代码:
# 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')