Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use #require instead of #required for parity with #permit -- #require…

…d is an alias until v1.0
  • Loading branch information...
commit 1e238a2170badcb9a5212e642220d7239246e9b4 1 parent dac840f
@dhh dhh authored
View
4 Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- strong_parameters (0.1.1)
+ strong_parameters (0.1.2)
actionpack (>= 3.2.0)
activemodel (>= 3.2.0)
@@ -29,7 +29,7 @@ GEM
hike (1.2.1)
i18n (0.6.0)
journey (1.0.3)
- multi_json (1.1.0)
+ multi_json (1.2.0)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
View
2  README.rdoc
@@ -25,7 +25,7 @@ In addition, parameters can be marked as required and flow through a predefined
# since you'll be able to reuse the same permit list between create and update. Also, you
# can specialize this method with per-user checking of permissible attributes.
def person_params
- params.required(:person).permit(:name, :age)
+ params.require(:person).permit(:name, :age)
end
end
View
4 lib/action_controller/parameters.rb
@@ -26,9 +26,11 @@ def permit!
self
end
- def required(key)
+ def require(key)
self[key].presence || raise(ActionController::ParameterMissing.new(key))
end
+
+ alias :required :require
def permit(*filters)
params = self.class.new
View
2  lib/strong_parameters/version.rb
@@ -1,3 +1,3 @@
module StrongParameters
- VERSION = "0.1.2"
+ VERSION = "0.1.3"
end
View
2  test/action_controller_required_params_test.rb
@@ -2,7 +2,7 @@
class BooksController < ActionController::Base
def create
- params.required(:book).required(:name)
+ params.require(:book).require(:name)
head :ok
end
end
View
2  test/parameters_require_test.rb
@@ -4,7 +4,7 @@
class ParametersRequireTest < ActiveSupport::TestCase
test "required parameters must be present not merely not nil" do
assert_raises(ActionController::ParameterMissing) do
- ActionController::Parameters.new(person: {}).required(:person)
+ ActionController::Parameters.new(person: {}).require(:person)
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.