Skip to content

Instantly share code, notes, and snippets.

@shanemcd
Created September 12, 2013 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shanemcd/6538369 to your computer and use it in GitHub Desktop.
Save shanemcd/6538369 to your computer and use it in GitHub Desktop.
# routes.rb
get '/:campaign' => 'campaigns#show', constraints: CampaignConstraint.new
# lib/campaign_constraint.rb
class CampaignConstraint
def matches?(request)
Campaign.exists?(name: request.params[:campaign])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment