Rails 3 路线帮助
这可能很简单,但我无法弄清楚。
我正在尝试通过 url“/submit”创建到 :submissions#new 的路由
resources :submissions, :only => [:index, :show, :new, :create]
match 'submit', :to => 'submissions#new'
上面的代码工作正常,但我想阻止标准“资源”创建的 URL “/submissions/new”并且仅使用“/submit”URL。我编写两个 URL 的方式都会呈现submissions#new,这是我不想要的。
当我注释掉“资源”代码行并仅使用“匹配”行时,它无法再找到控制器“submissions_controller”
这是错误消息:
ActionController::RoutingError in Submissions#new
Showing /media/sf_admin/ Projects/lolsnort/app/views/submissions/_form.html.erb 其中第 1 行提出:
没有路由匹配 {:controller=>"submissions"}
任何帮助将不胜感激。谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试一下这个方法:
Try this way out: