Reputation: 43
Is there any way I can apply constraints to the query string in Rails routes?
Valid routes: /path/?type=A
and /path/?type=B
Any other type should be invalid route. For eg. /path/?type=C
should be invalid(400 Bad request)
Upvotes: 2
Views: 518
Reputation: 36860
You can do this in your action...
def my_action
raise ActionController::BadRequest unless %w(A B).include?(params[:type])
... # normal actions here
end
Upvotes: 2