Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Rails 3.0+ Compatibility #13

wants to merge 1 commit into from

5 participants


I went ahead and isolated the issues that were causing failures using strong_parameters with rails 3.0 stable. I'm not entirely sold on my proposed solution, but figured I'd get the conversation started on the best way to achieve 3.0+ compatibility :)


We just got another solution merged for the dup. Can you update and see if that fixes the problem? Otherwise I'm glad to see this become 3.0 compatible.


I tested with the recently merged dup solution (#12), but the test was still failing in rails 3-0 stable due to 3.0's HashWithIndifferentAccess#dup not using

I went ahead and merged the recent dup solution with the 3.0 fix and updated the commit. Tests are now fully passing in 3.0 and 3.2. Let me know if that works!


A new test failure has also arisen from the use of module_namespacing (introduced in Rails 3.1) in the controller scaffold template:

Finished tests in 0.263376s, 98.7182 tests/s, 212.6238 assertions/s.

  1) Error:
NoMethodError: undefined method `module_namespacing' for #<Rails::Generators::StrongParametersControllerGenerator:0x007fcbb4dde190>
    (erb):1:in `template'

26 tests, 56 assertions, 0 failures, 1 errors, 0 skips

The current fixes in this pull request would make strong_parameters compatible with Rails 3.1, but fixing this failure for 3.0 would be hacky.

dhh commented

I'd be happy with 3.1 compatibility, then. Can we update this PR to get that done?


This PR doesn't work with the current code base - rails 3.0 or 3.1. I've opened a new pull request for adding rails 3.1 compatibility here: #46.


Closing this in favor of #46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 31, 2012
  1. @joslynesser

    Rails 3.0+ Compatibility

    joslynesser authored
This page is out of date. Refresh to see the latest.
5 lib/action_controller/parameters.rb
@@ -29,7 +29,7 @@ def permit!
def require(key)
self[key].presence || raise(
alias :required :require
def permit(*filters)
@@ -75,7 +75,8 @@ def slice(*keys)
def dup
- super.tap do |duplicate|
+ do |duplicate|
+ duplicate.default = default
duplicate.instance_variable_set :@permitted, @permitted
3  lib/active_model/forbidden_attributes_protection.rb
@@ -3,7 +3,8 @@ class ForbiddenAttributes < StandardError
module ForbiddenAttributesProtection
- def sanitize_for_mass_assignment(new_attributes, options = {})
+ def sanitize_for_mass_assignment(*args)
+ new_attributes = args.first
if !new_attributes.respond_to?(:permitted?) || (new_attributes.respond_to?(:permitted?) && new_attributes.permitted?)
4 strong_parameters.gemspec
@@ -14,8 +14,8 @@ do |s|
s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
s.test_files = Dir["test/**/*"]
- s.add_dependency "actionpack", ">= 3.2.0"
- s.add_dependency "activemodel", ">= 3.2.0"
+ s.add_dependency "actionpack", ">= 3"
+ s.add_dependency "activemodel", ">= 3"
s.add_development_dependency "rake"
Something went wrong with that request. Please try again.