rails 3 删除控制器名称表单 url [英] rails 3 removing controller name form url
本文介绍了rails 3 删除控制器名称表单 url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在 rails 3 应用程序中设置一些半静态页面我创建了一个带有一些非 Restful 操作的 Pages 控制器
I'm trying to set up some semistatic page in a rails 3 app I've created a Pages controller with some non restful actions
class PagesController < ApplicationController
def home
end
def about
end
def contact
end
def monday
end
def saturday
end
def sunday
end
end
它显示在/pages/home 等.有没有办法重新路由页面,以便它们显示在/home 等下
It's showing at /pages/home etc. Is there a way to re-route the pages so that they show under /home etc.
我试过了
resources :pages, :path => '/' do
#blah
end
但我收到一条错误消息,告诉我 :action => 显示丢失.是否可以将设置应用于所有非 Restful 操作?
but I get an error message telling me that the :action => show is missing. Is it possible to apply a setting to all non restful actions?
推荐答案
您可以添加收集路线:
resources :pages do
collection do
get 'home'
get 'about'
get 'contact'
...
end
end
这篇关于rails 3 删除控制器名称表单 url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文