Reputation: 1975
I have route like this wrapped by constraint.
constraints DomainConstraint.new('admin.example.com') do
get '/admin/:page', to: 'admin#browse', as: :admin_index
end
constraints DomainConstraint.new('client.example.com') do
get '/:page', to: 'client#index', as: :client_index
end
Now, When I want to redirect request from admin.example.com
controller to client
controller via:
def some_page
redirect_to action: :client_index,
end
It says:
No route matches
I believe this happens because I wrapped routes with constraint. How can i redirect admin to client using constraints
?
Upvotes: 0
Views: 151
Reputation: 4378
The reason why your code is not working because action
params takes the name of action on the same controller if you don't specify the controller name.
Change your code from
def some_page
redirect_to action: :client_index,
end
To
def some_page
redirect_to controller: 'client', action: :index
end
More info on redirect_to
here
Upvotes: 2