Rails Routing ActiveRecord::RecordNotFound Error <p>I added a new controller action and added correspondent route</p> <pre><code> def students @students = Swimming::Student.all render :json =&gt; @students end namespace :swimming do resources :classschedules do get 'students', :action =&gt; 'students', :as =&gt; :students ,:on =&gt; :collection end end </code></pre> <p>but when I access this page </p> <pre><code>http://localhost:3000/swimming/classschedules/students </code></pre> <p>I got this error</p> <pre><code>ActiveRecord::RecordNotFound in Swimming::ClassschedulesController#show Couldn't find Swimming::Classschedule with id=students </code></pre> <p>It looks like rails tries to load another route</p> <pre><code>GET /swimming/classschedules/:id(.:format) swimming/classschedules#show </code></pre> <p>I am attaching all related routes</p> <pre><code> swimming_classschedules GET /swimming/classschedules(.:format) swimming/classschedules#index POST /swimming/classschedules(.:format) swimming/classschedules#create new_swimming_classschedule GET /swimming/classschedules/new(.:format) swimming/classschedules#new edit_swimming_classschedule GET /swimming/classschedules/:id/edit(.:format) swimming/classschedules#edit swimming_classschedule GET /swimming/classschedules/:id(.:format) swimming/classschedules#show PUT /swimming/classschedules/:id(.:format) swimming/classschedules#update DELETE /swimming/classschedules/:id(.:format) swimming/classschedules#destroy date_swimming_classschedules GET /swimming/classschedules/date/:date(.:format) swimming/classschedules#date students_swimming_classschedules GET /swimming/classschedules/students(.:format) swimming/classschedules#students editnote_swimming_classschedules POST /swimming/classschedules/editnote/:date(.:format) swimming/classschedules#editnote GET /swimming/classschedules(.:format) swimming/classschedules#index POST /swimming/classschedules(.:format) swimming/classschedules#create GET /swimming/classschedules/new(.:format) swimming/classschedules#new GET /swimming/classschedules/:id/edit(.:format) swimming/classschedules#edit GET /swimming/classschedules/:id(.:format) swimming/classschedules#show PUT /swimming/classschedules/:id(.:format) swimming/classschedules#update DELETE /swimming/classschedules/:id(.:format) swimming/classschedules#destroy </code></pre> <p>How to fix this issue?</p> <p><strong>UPDATE</strong> *<em>it has been fixed</em>*</p> <p>The issue because I had two blocks of </p> <pre><code> namespace :swimming do resources :classschedules do end end </code></pre> <p>in routes.rb</p>