Skip to content

Instantly share code, notes, and snippets.

@erez-rabih
Created October 7, 2012 00:16
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 erez-rabih/3846596 to your computer and use it in GitHub Desktop.
Save erez-rabih/3846596 to your computer and use it in GitHub Desktop.
Bad routing filter example
# routes.rb
match 'posts/filter/:by_attribute/:value' => 'posts#filter'
# posts_controller.rb
class PostsController < ApplicationController
def filter
if ["title", "content", "author_name", "post_number"].include? params[:by_attribute]
@posts = Post.where(params[:by_attribute] => params[:value])
else
render :nothing => true, :status => :not_found
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment