Note that there are some explanatory texts on larger screens.

plurals
  1. PORails - From RESTFul resource to customized routes
    primarykey
    data
    text
    <p>This is a design problem that I am trying to figure out. I will explain what I have right now, and what I would like to have:</p> <p><strong>1. Actual design</strong></p> <p>I have a defined a <code>resources :users</code> and by doing so I have defined different actions such as new, create and update in the Users controller. This is working as expected by following <em>urls</em> like users/new , users/:id, etc... Now I want to go one step forward, and I want to be able to do the following...</p> <p><strong>2. What am I looking for</strong></p> <p>I want to be able to have a route like this:</p> <pre><code>users/overview/profile - This should be equivalent to `users/:id` (show action) users/overview/network - This should be equivalent to users/:id/network (list of networks for that user) </code></pre> <p><strong>3. My idea</strong></p> <p>My first idea was to define something like this:</p> <pre><code>resource :users do namespace :overview do resource :networks end end </code></pre> <p>But this would work for urls like: users/:id/overview/networks and I don't want the user id to be shown in the URL. So my questions are:</p> <p>1 - How can I deal with users/overview/networks instead of users/:id/overview/networks , assuming that I can get the user id from session.</p> <p>2 - How can I be able to manage URLs like this: <code>users/overview/profile</code> where actually a profile is just the show method of <code>users/:id</code> Right now I have defined all the actions in the users controller and everything is working fine (new,delete,create,update...) I just don't know how to move into that "namespace" overview/profile</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload