Rails 3 Routes Help
this is probably simple, but I can't figure it out.
I'm trying to create a route to :submissions#new via the url "/submit"
resources :submissions, :only => [:index, :show, :new, :create]
match 'submit', :to => 'submissions#new'
The code above works fine, but I want to block the standard "resources" created URL of "/submissions/new" and only use the "/submit" URL. The way I have it written both URLs will render submissions#new, which I don't want.
When I comment out the "resources" line of 开发者_运维技巧code and only use the "match" line, it can no longer find the controller "submissions_controller"
Here is the error message:
ActionController::RoutingError in Submissions#new
Showing /media/sf_admin/Projects/lolsnort/app/views/submissions/_form.html.erb where line #1 raised:
No route matches {:controller=>"submissions"}
Any help would be appreciated. Thanks.
Try this way out:
resources :submissions, :except => [:new]
match 'submit', :to => 'submissions#new', :as => :submit
精彩评论