I setup some routes like so:
resources :stormtroopers, :only => [:show, :index, :update, :edit]
I suspected that the new action when I hit the url ‘/stormtroopers/new’ would not be available, however the show action is trying to look up the id ‘new’
my rspec test says it all
expected {:get=>”/stormtroopers/new”} not to be routable, but it routes to {:action=>”show”, :controller=>”stormtroopers”, :id=>”new”}
is this correct behavior on rails part? I don’t think its my route?
You have no route anymore for your
newaction because you removed it.But the show action is looking for
/stormtroopers/something. With no constraint onsomething.That’s why it matches this route and triggers this action.
Usually, the
resourcesdefines internallynewbeforeshowand that works because the rule in routing is: first matched, first served.So it’s just logic, clear?