Rails - Dynamic routing based on host & ID

六眼飞鱼酱① 提交于 2019-12-11 10:03:03

问题


I have a rails application that contains many user pages. When a user wants to point a domain at this page, how would I do that?

Right now I've tested out this, and it works -
root :to => "controller#show", :id => 4, :constraints => {:host => "www.exampleurl.com"}

but need to convert this to be dynamic, so that after I migrate a column into the model called domain it checks domain and serves it the proper ID.

something like -
root :to => 'controller#show', :id => ':id', :constraints => {:host => ':domain'}

What would something like this look like?

来源:https://stackoverflow.com/questions/19346108/rails-dynamic-routing-based-on-host-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!