Reputation: 113
I created this file: views/lendings/terms.html.erb
lendings controller works fine for the other views.
I just want to write a link from views/lendings/show to terms.html.erb view
Do i have to write an action in lendings controller just to do that?
How do I configure the routes file? How do I create the link in show view?
<%= link_to 'read terms', lendings_terms_path %> ?
Thanks!
Upvotes: 0
Views: 29
Reputation: 113
I tried this and it didn't work
resources :lendings do
collection do
get :terms
end
end
Then it worked with:
resources :lendings do
member do
get 'terms'
end
end
As explained in: Adding More RESTful Actions/2.10.1 Adding Member Routes.
Check: http://guides.rubyonrails.org/routing.html
Upvotes: 0
Reputation: 18540
Yes. you need to create an action called terms
inside LendingsController
. If you don't need anything special in the view, then you can just leave the method empty. Then in the routes file add this:
resources :lendings do
collection do
get :terms
end
end
Upvotes: 1