简体   繁体   English

Rails是否等效于Django的“站点”框架?

[英]Rails equivalent of Django's “sites” framework?

I'm in the process of learning Ruby on Rails, and I'm coming from just learning the Django framework. 我正在学习Ruby on Rails,而我只是从学习Django框架而来。 One thing that I liked about Django was the Sites Framework . 我喜欢Django的一件事是Sites Framework Is there any equivalent of this in Rails? Rails中有与此等效的东西吗?

Basically, I'm looking to have a single Rails app be run for multiple sites - and I want to filter models automagically based on the hostname. 基本上,我希望为多个站点运行一个Rails应用程序-我想根据主机名自动过滤模型。 I'm currently working with Rails 3.0.5. 我目前正在使用Rails 3.0.5。 Any thoughts/links/examples would be greatly appreciated! 任何想法/链接/示例将不胜感激!

I actually spent a lot of time researching this recently. 实际上,我最近花了很多时间对此进行研究。 The quick answer is no, there isn't a clear equivalent. 快速的答案是“否”,没有明确的对等物。 You can approach that kind of behavior from two sides, depending on how independent you want your sites to be. 您可以从两个方面来处理这种行为,具体取决于您希望网站变得多么独立。 On the more independent side, you can have multiple apps that share behavior by using Rails Engines , where you basically package your parent app as a gem. 在更独立的方面,您可以使用Rails Engines共享多个行为,这些应用程序基本上将您的父应用程序打包为gem。 On the less independent side, there are various things you can do to customize a single app's behavior based on domain/subdomain . 在不太独立的方面,您可以执行多种操作来基于domain / subdomain定制单个应用程序的行为

Which of these is closer to what you want? 其中哪个更接近您想要的? What kinds of things are you looking to customize? 您要定制什么类型的东西?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM