开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜