Rails routes redirection for subdomains

。_饼干妹妹 提交于 2019-12-05 05:56:08
Stefan Huska

According to @cfernandezlinux's amazing answer, here's the same in Rails 4/Ruby 2 syntax:

constraints subdomain: "meow" do   
  get "/" => redirect { |params| "http://www.externalurl.com" }
end
  • match in routes.rb is not allowed in Rails 4.0 anymore. You have to use explicitly get, post, etc.
  • hashrocket syntax (=>) is for old Ruby, now in Ruby 2.0 we use param: 'value' syntax
cfernandezlinux

I ended up doing something like this:

constraints :subdomain => "meow" do   
  match "/" => redirect { |params| "http://www.externalurl.com" }
end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!