Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are Rails 3 Subdomains Fairly Painless?

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.com'.

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.

like image 827
Dex Avatar asked Nov 05 '22 07:11

Dex


1 Answers

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

like image 128
Jamie Wong Avatar answered Nov 09 '22 02:11

Jamie Wong