Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems with Routing Resources
    primarykey
    data
    text
    <p>I am setting up a Rails site using <code>map.resources</code> and <code>map.resource</code>, and I am encountering a limitation (as far as I know at least).</p> <p>Here is my current routing.</p> <pre><code>map.with_options :conditions =&gt; { :subdomain =&gt; true } do |sub| sub.root :controller =&gt; 'company' sub.resource :company do |company| company.resources :clients, :path_prefix =&gt; nil, :name_prefix =&gt; nil, :collection =&gt; { :sort =&gt; :post } do |clients| clients.resources :projects, :path_prefix =&gt; ":client/:project" end end sub.resource :user, :collection =&gt; { :logout =&gt; :get } end </code></pre> <p>In a general sense this is my wanted outcome:<br /> <strong>/client-name/action</strong><br />Calls the Clients controller, and passes the client-name as some sort of hash that is the same.<br /><br /> <strong>/client-name/project-name/action</strong><br />Calls the Projects controller, but passes the client-name as a hash that stays the same. It wants to pass that as an id.</p> <p>I am hoping to keep my URL structure very basic, so:<br /></p> <ol> <li>client-name = yahoo</li> <li>project-name = login-page</li> </ol> <p>/client-name/ - This should use the <code>Clients.show</code> method.<br /> /client-name/edit - This should use the <code>Clients.edit</code> method.<br /> /client-name/project-name - This should use the <code>Projects.show</code> method.<br /> /client-name/project-name/edit - This should use the <code>Projects.edit</code> method.<br /></p> <p>Although with my current routing it is being interpreted as such:<br /> /client-name/projects - This is using the <code>Projects.index</code> method.<br /> /clients/client-name - This is using the <code>Clients.show</code> method.<br /><br /><br /> I really appreciate any help that is given.</p>
    singulars
    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