[英]pages controller but route to root/title
I've been using static pages in my rails app (ie "/about" "/contact" etc); 我一直在我的Rails应用程序中使用静态页面(即“ / about”“ / contact”等); the client wants to be able to create pages, control/change the content and still keep the default root/page route.
客户希望能够创建页面,控制/更改内容并仍保留默认的根目录/页面路由。
I've got a page controller with title /content and am using FriendlyID elsewhere, but I'm not sure how I can best change the default /page/about to map to /about 我有一个标题为/ content的页面控制器,并在其他地方使用FriendlyID,但是我不确定如何最好地更改默认的/ page / about来映射到/ about
What would be the proper way of doing this? 这样做的正确方法是什么?
If I understand your question what you need is: 如果我了解您的问题,那么您需要的是:
get :about, to: 'pages#about', as: :about
Running rake routes, you will get: 运行耙道,您将获得:
about GET /about(.:format) pages#about
In your links or controller use about_path
. 在您的链接或控制器中使用
about_path
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.