Skip to content
Browse files

Add Rails 3.0.x support

  • Loading branch information...
1 parent 8cd920b commit 0d21cc58167df513ee9581170c862901697b3827 @fixlr fixlr committed with grosser Oct 20, 2012
View
8 Gemfile.lock
@@ -2,9 +2,9 @@ PATH
remote: .
specs:
strong_parameters (0.1.6.dev)
- actionpack (~> 3.1)
- activemodel (~> 3.1)
- railties (~> 3.1)
+ actionpack (~> 3.0)
+ activemodel (~> 3.0)
+ railties (~> 3.0)
GEM
remote: http://rubygems.org/
@@ -34,7 +34,7 @@ GEM
metaclass (0.0.1)
mocha (0.12.0)
metaclass (~> 0.0.1)
- multi_json (1.3.6)
+ multi_json (1.3.7)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
View
3 lib/action_controller/parameters.rb
@@ -83,7 +83,8 @@ def slice(*keys)
end
def dup
- super.tap do |duplicate|
+ self.class.new(self).tap do |duplicate|
+ duplicate.default = default
duplicate.instance_variable_set :@permitted, @permitted
end
end
View
3 lib/active_model/forbidden_attributes_protection.rb
@@ -3,7 +3,8 @@ class ForbiddenAttributes < StandardError
end
module ForbiddenAttributesProtection
- def sanitize_for_mass_assignment(new_attributes, options = {})
+ def sanitize_for_mass_assignment(*options)
+ new_attributes = options.first
if !new_attributes.respond_to?(:permitted?) || new_attributes.permitted?
super
else
View
6 lib/generators/rails/strong_parameters_controller_generator.rb
@@ -5,6 +5,12 @@ module Generators
class StrongParametersControllerGenerator < ScaffoldControllerGenerator
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
source_root File.expand_path("../templates", __FILE__)
+
+ if ::Rails.version < '3.1'
+ def module_namespacing
+ yield if block_given?
+ end
+ end
end
end
end
View
6 strong_parameters.gemspec
@@ -14,9 +14,9 @@ Gem::Specification.new do |s|
s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
s.test_files = Dir["test/**/*"]
- s.add_dependency "actionpack", "~> 3.1"
- s.add_dependency "activemodel", "~> 3.1"
- s.add_dependency "railties", "~> 3.1"
+ s.add_dependency "actionpack", "~> 3.0"
+ s.add_dependency "activemodel", "~> 3.0"
+ s.add_dependency "railties", "~> 3.0"
s.add_development_dependency "rake"
s.add_development_dependency "mocha", "~> 0.12.0"

1 comment on commit 0d21cc5

@biow0lf

Thanks!

Please sign in to comment.
Something went wrong with that request. Please try again.