Reputation: 2753
When I access to http://testuser.example.com, I'd like it to access to 'user' controller's 'show' action with the parameter 'testuser', which is user name in user Model.
How can I archive this easily??
Upvotes: 2
Views: 816
Reputation: 2694
This should work
@user = User.find_by_name(request.subdomain)
update
for routes
constraints(:subdomain => /.+/) do
root :to => 'user#show'
end
simply you define new routing rules when subdomain exists, you can change it according to your needs.
Upvotes: 4