Note that there are some explanatory texts on larger screens.

plurals
  1. POHas namedspaced routing changed in Rails 2.3?
    primarykey
    data
    text
    <p>I have an admin namespace which gives me the usual routes such as admin_projects and admin_project, however they are not behaving in the usual way. This is my first Rails 2.3 project so maybe related I can't find any info via Google however.</p> <pre><code>map.namespace(:admin) do |admin| admin.resources :projects end </code></pre> <p>The strange thing is for a given URL (eg. /admin/projects/1) I don't have to pass in an object to get URL's it somehow guesses them:</p> <pre><code>&lt;%= admin_project_path %&gt; # =&gt; /admin/projects/1 </code></pre> <p>No worries, not really a problem just not noticed this before.</p> <p>But if I try and pass an object as is usual:</p> <pre><code>&lt;%= admin_project_path(@project) %&gt; # =&gt; admin_project_url failed to generate from {:controller=&gt;"admin/projects", :action=&gt;"show", :id=&gt;#&lt;Project id: 1, name: "teamc...&gt; </code></pre> <p>":id" seems to contain the entire object, so I try passing the id directly and it works:</p> <pre><code>&lt;%= admin_project_path(@project.id) %&gt; # =&gt; /admin/projects/1 </code></pre> <p>This would not be so bad but when it comes to forms I usually use [:admin, @object], however:</p> <pre><code>&lt;%= url_for [:admin, @project.id] %&gt; # =&gt; undefined method `admin_fixnum_path' </code></pre> <p>So I can't pass in an id, as it needs an objects class to work out the correct route to use.</p> <pre><code>&lt;%= url_for [:admin, @project] %&gt; # =&gt; Unfortunately this yields the same error as passing a object to admin_project_path, which is what it is calling. </code></pre> <p>I can't spot any mistakes and this is pretty standard so I'm not sure what is going wrong...</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