Skip to content

Instantly share code, notes, and snippets.

@hmans
Created July 24, 2013 11:17
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 hmans/6069728 to your computer and use it in GitHub Desktop.
Save hmans/6069728 to your computer and use it in GitHub Desktop.
Make CanCan 1.6 work with Rails 4 (or Rails 3 with StrongParameters)
class ApplicationController < ActionController::Base
# ...
# Workaround for CanCan vs. SecureParameters.
# Invokes #secure_params and merges the returned hash back into #params.
#
prepend_before_filter only: [:create, :update] do
secure_params.each do |k, v|
params[k] &&= v
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment