Skip to content

Instantly share code, notes, and snippets.

@vparihar01
Created April 26, 2013 05:38
Show Gist options
  • Save vparihar01/5465249 to your computer and use it in GitHub Desktop.
Save vparihar01/5465249 to your computer and use it in GitHub Desktop.
Controllers should sanitize params before performing any other logic.
class ExampleController < ActionController::Base
def create
Example.create(sanitized_params)
end
def update
Example.find(params[:id]).update_attributes!(sanitized_params)
end
protected
def sanitized_params
params[:example].slice(:expected_param, :another_expected_param)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment