Note that there are some explanatory texts on larger screens.

plurals
  1. POnested namespace route going to wrong controller
    primarykey
    data
    text
    <p>Using Rails 3.0.7, I'm creating an API for our app, and I have this setup:</p> <p>routes.rb</p> <pre><code> namespace :api do namespace :v1 do match "connect" =&gt; "users#login", :via =&gt; :post match "disconnect" =&gt; "users#logout", :via =&gt; :post resources :users match "users/:id/foos" =&gt; "foos#list", :via =&gt; :get match "users/:id" =&gt; "users#update", :via =&gt; :put match "foos/:id/bars" =&gt; "bars#list_by_foo", :via =&gt; :get match "foos/:id" =&gt; "foos#show", :via =&gt; :get, :constraints =&gt; { :id =&gt; /\d+/ } match "bars/:id" =&gt; "bars#show", :via =&gt; :get end end # other routes here e.g. match "users/find" =&gt; "users#find_by_name", :via =&gt; :get match "users" =&gt; "users#create", :via =&gt; :post </code></pre> <p>And then I have my regular <code>app/controllers/application_controller.rb</code> and <code>app/controllers/users_controller.rb</code> files as well as my <code>app/controllers/api/v1/application_controller.rb</code> and <code>app/controllers/api/v1/users_controller.rb</code> files that are defined like the following:</p> <pre><code>class Api::V1::ApplicationController &lt; ApplicationController before_filter :verify_access def verify_access # some code here end end class Api::V1::UsersController &lt; Api::V1::ApplicationController skip_before_filter, :except =&gt; [:show, :update, :delete] end </code></pre> <p>And before everything seemed to be working right until I overrode a method that is shared by both UsersController and Api::V1::UsersController -- and now it seems like everything is pointing to UsersController even though I'm accessing through the api/v1/users route.</p> <p>I'm at my wit's end trying to figure it out. Any suggestions? Thanks. PS - feel free to comment with whatever conventions I'm ignoring that I shouldn't be or other things I might have messed up :)</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