Skip to content

Commit 89b6e45

Browse files
committed
Add support for Rails 3
1 parent 625ae85 commit 89b6e45

File tree

5 files changed

+7
-5
lines changed

5 files changed

+7
-5
lines changed

Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ source 'https://rubygems.org'
22

33
gemspec
44

5-
65
group :test do
76
gem 'rspec-rails'
87
gem 'simplecov', require: false

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ PATH
22
remote: .
33
specs:
44
request_params_validation (0.1.0)
5-
rails (>= 5)
5+
rails (>= 3)
66

77
GEM
88
remote: https://rubygems.org/

lib/request_params_validation/params.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def self.filter!(definition, params)
1717
extra_keys = [:controller, :action] # Keys added by Rails
1818

1919
filter_params(definition, params, extra_keys).tap do |params|
20-
params.permit! if params.is_a?(ActionController::Parameters)
20+
params.permit! if params.respond_to?(:permit!)
2121
end
2222
end
2323

lib/request_params_validation/params/types/validations.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ def valid_array?(value)
88

99
def valid_hash?(value)
1010
value.is_a?(Hash) || value.is_a?(ActionController::Parameters)
11+
rescue NameError # For older versions of Rails
12+
false
1113
end
1214

1315
def valid_string?(value)

request_params_validation.gemspec

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
$:.push File.expand_path("lib", __dir__)
1+
lib = File.expand_path('../lib', __FILE__)
2+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
23

34
require 'request_params_validation/version'
45

@@ -17,5 +18,5 @@ Gem::Specification.new do |spec|
1718

1819
spec.files = Dir["{lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
1920

20-
spec.add_dependency 'rails', '>= 5'
21+
spec.add_dependency 'rails', '>= 3'
2122
end

0 commit comments

Comments
 (0)