mardi 23 juin 2015

Accessing URI params in the controller

(Learning RoR on my own, so pls forgive me if this is an obvious question) I have an app to track books stored on shelves in libraries. A request should come in like:

GET books/library_id   => shows all books on every shelf in a library
GET books/library_id/shelf_id  => shows all books on one shelf in a library
GET books/library_id/shelf_id/book_id  => shows a particular book

POST would use similar formats, except I will be using JSON in the POST body to supply the information (author, pub date, length, etc) for the book, shelf, or library

My question is, [:params] passed in to my controller seems to hold query (anything after a ?) and POST body parameters, but not the URL, which I need to parse and use to determine what to show. Is there a way to get this out of the parameters? I'm trying to avoid something like GET /books/?library_id/shelf_id

Aucun commentaire:

Enregistrer un commentaire