Reputation: 1566
Ok, say you have this:
match "tutor_appointments/new_appt" => "tutor_appointments#new_appt"
How do I create a link_to
path from it?
Would it be something like this: (it doesn't work, btw)
<%= link_to "New Appointments", controller:tutor_appointments, method:new_appt %>
I'm always confused on routing stuff when it comes to figuring out how to do link_to
link.
I do understand that tutor_appointments
is the controller and new_appt
is the method.
Upvotes: 0
Views: 220
Reputation: 25029
Ideally, you would name the route:
http://guides.rubyonrails.org/routing.html#naming-routes
And then you can refer to the route by that name.
eg. if you had:
match "tutor_appointments/new_appt" => "tutor_appointments#new_appt", as: 'new_appointment'
Then you could do:
link_to 'New Appointments', new_appointment_path
However, in this case it sounds like what you actually want is resource routing:
http://guides.rubyonrails.org/routing.html#resources-on-the-web
And you want a 'new' action for your 'tutor_appointments' resource.
Upvotes: 3