← Back to Upcase

Routing strangeness


(Jon Seidel) #1

I’m converting an application and adding specs so I have created a new Rails 3 app and am writing specs and migrating code over from the old app to the new as needed to get things to pass…

But I’m having a strange problem with routes – any routes that I specify with ‘resource’ or ‘resources’ vanish. Rake routes has nothing for them and tests fail. For example:

resources :accounts, :only => [':get, :post]
resources :assets, only: [:index]

result in no output from rake routes. However, things like:

root to: 'welcome#index', via: 'get'
get 'welcome/feedback', :controller => 'welcome', :action => 'feedback'

work as expected. The rake routes output from these four directives is simply:

            root GET /                           welcome#index
welcome_feedback GET /welcome/feedback(.:format) welcome#feedback

I must be missing something really simple – I’ve used these before in other Rails3 apps.with no problems but I just can’t figure this one out.


(Jon Seidel) #2

Duh… two minutes after I posted this, I saw the problem. :get & :post aren’t part of the standard set of resourceful routes so nothing is generated. And no error message is displayed - just silence. I meant to put :new, :create and, of course, that works just fine.


(Jon Seidel) #3

This could still happen to someone by just making a little typo, so I blogged about it at http://www.nubyrubyrailstales.com/2013/06/silence-is-not-golden.html. Hopefully it’ll help someone out some time.