开发者

Are Rails 3 Subdomains Fairly Painless?

开发者 https://www.devze.com 2023-01-23 20:34 出处:网络
I have an app with two sections, Buyers and Sellers. The main section \'/\' is for Buyers, but I have a separate Sellers portal that I\'m currently placing in /sellers. Might be nicer to move the sell

I have an app with two sections, Buyers and Sellers. The main section '/' is for Buyers, but I have a separate Sellers portal that I'm currently placing in /sellers. Might be nicer to move the sellers to their own subdomain like 'sellers.mydomain.co开发者_StackOverflow社区m'.

Subdomains don't seem to be extremely popular and I've read things like they make testing difficult, etc. Wondering what you all have to say about the issue.


There are a few things that make testing a bit of pain with subdomains, but introducing subdomains as a real supported feature in rails 3 has somewhat mitigated these problems.

EDIT: Adding something like this to your test helper can make testing a lot easier and more readable.

  def set_subdomain(sub)
    @request.host = sub.present?? "#{sub}.test.host" : "test.host"
  end

EDITx2:

http://www.railscasts.com/episodes/221-subdomains-in-rails-3

0

精彩评论

暂无评论...
验证码 换一张
取 消