我的很多用户一直都是http://(rails app URL)/blog
,但我实际上没有博客.我终于建立了一个Posterous博客,现在想把我的用户 bootstrap 到那里.有没有一种方法可以使用路由来配置它.rb?有没有更好的方法不需要编辑httpd.档案?
我的很多用户一直都是http://(rails app URL)/blog
,但我实际上没有博客.我终于建立了一个Posterous博客,现在想把我的用户 bootstrap 到那里.有没有一种方法可以使用路由来配置它.rb?有没有更好的方法不需要编辑httpd.档案?
取决于您使用的Rails版本.
Rails 3
# in routes.rb
match "/blog" => redirect("http://example.com/blog"), :as => :blog
Rails 2
# in routes.rb
map.blog '/blog',
:controller => "a_helper_controller",
:action => "redirect_to_blog"
# in a_helper_controller.rb
def redirect_to_blog
redirect_to "http://example.com/blog"
end