What are the paths that is automatically added by Rails? Let say you have a Question resource you automatically get questions_path, question_path etc. Where do I see what they resolve to and what I get?
This section might be helpful http://guides.rubyonrails.org/routing.html#specifying-a-controller-to-use
Verb Path Action Helper GET /photos index photos_path GET /photos/new new new_photo_path POST /photos create photos_path GET /photos/:id show photo_path(:id) GET /photos/:id/edit edit edit_photo_path(:id) PUT /photos/:id update photo_path(:id) DELETE /photos/:id destroy photo_path(:id) If you want to create a helper for show action you can write
photo_path(@photo.id) where @photo is your model object. Or you can pass @photo directly if it responds to id method.
photo_path(@photo) edit_photo_path(@photo) You can also load rails console (in terminal) and test routes using app like so app.photo_path(1) (it will show you the route for the photo with id equals 1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With