Could you do something along the lines of:

%w(benwilson sunset_events).each do |subdomain|
  constraints(SubDomainMatcher.new(subdomain)) do
    controller(subdomain.to_sym) do
      get "/", :action=>:index
      get :sign_up, :action=> :sign_up
    end
  end
end

Do you mind if I ask why you're using multiple controllers like this? 


On 18/08/2011, at 4:24 PM, Tim Uckun wrote:

>> 
>> You seem to have a defined list of controllers and a mapping of subdomains ?
> 
> Yea basically.
> 
> I want foo.domain.com to map to the equivalent of app.com/foo that is
> go to foo_controller.rb
> 
> 
>> I'm not sure either listing them out in the routes file, or using multiple
>> constraints for each group of subdomains would not work?
> 
> This works but seems clumsy
> 
> constraints(SubDomainMatcher.new('benwilson')) do
>    controller :ben_wilson do
>      get "/", :action=>:index
>      get :sign_up, :action=> :sign_up
>    end
>  end
>   constraints(SubDomainMatcher.new('sunset_events')) do
>    controller :sunset_events do
>      get "/", :action=>:index
>      get :sign_up, :action=> :sign_up
>    end
>  end
> 
> 
> It would be so much nicer if I could specify the controller via a
> variable but just can't seem to get that to work.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "WellRailed" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/wellrailed?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"WellRailed" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/wellrailed?hl=en.

Reply via email to