更改索引页面 - Ruby on Rails
我是 Rails 新手,所以放轻松。我已经开发了我的博客并成功部署了它。整个应用程序基于 post_controller。我想知道如何将用户路径重新路由到默认的 post_controller 与应用程序控制器。
举例来说,如果您访问 http://mylifebattlecry.heroku.com,您将看到默认的 Rails 页面。如果您访问 http://mylifebattlecry.heroku.com/posts 您将看到该应用程序。完成此操作后,我将更改我的域 http://www.mylifebattlecry.com 以映射到 Heroku,但需要了解如何将 /posts 发送到访问者所在的位置。
I am new to rails so go easy. I have developed my blog and deployed it successfully. The entire app is based out of the post_controller. I am wondering how I can reroute the users path to default to the post_controller vs. the app controller.
To illustrate, if you go to http://mylifebattlecry.heroku.com you will see the default rails page. If you go to http://mylifebattlecry.heroku.com/posts you will see the the app. Once I complete this I will change my domain of http://www.mylifebattlecry.com to map to Heroku but need to know how to get the /posts to be where the visitor is sent.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要做两件事
map.root :controller =>; “posts”#RAILS 2
或
root :to => 'posts#index' #RAILS 3
然后,这将调用帖子控制器中的索引操作。
您需要重新启动应用程序才能看到对routes.rb的更改
You need to do two things
map.root :controller => "posts" #RAILS 2
or
root :to => 'posts#index' #RAILS 3
This will then call the index action in your posts controller.
You will need to restart the application to see changes to routes.rb
将以下行添加到confing/routes.rb:
之后您需要重新启动服务器。
Add the following line to your confing/routes.rb:
You need to restart your server after that.