You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When my strong parameters method is defined as follows (using fetch rather than require):
def order_params
# use params.fetch rather than params.require to handle cases where params are empty
params.fetch(:order, {}).permit(:eta, :diner_id)
end
I run into the following failure:
4) Restaurant::OrdersController POST create should permit POST #create to receive parameters :eta and :diner_id
Failure/Error: it { should permit(:eta, :diner_id).for(:create) }
TypeError:
no implicit conversion of nil into Array
# /usr/local/rvm/gems/ruby-2.1.1/gems/awesome_print-1.2.0/lib/awesome_print/core_ext/array.rb:20:in `-'
# /usr/local/rvm/gems/ruby-2.1.1/gems/awesome_print-1.2.0/lib/awesome_print/core_ext/array.rb:20:in `call'
# /usr/local/rvm/gems/ruby-2.1.1/gems/awesome_print-1.2.0/lib/awesome_print/core_ext/array.rb:20:in `block (2 levels) in <class:Array>'
# /usr/local/rvm/gems/ruby-2.1.1/bundler/gems/shoulda-matchers-8f933f80647e/lib/shoulda/matchers/action_controller/strong_parameters_matcher.rb:83:in `parameters_difference'
# /usr/local/rvm/gems/ruby-2.1.1/bundler/gems/shoulda-matchers-8f933f80647e/lib/shoulda/matchers/action_controller/strong_parameters_matcher.rb:52:in `failure_message'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-expectations-2.14.5/lib/rspec/expectations/handler.rb:30:in `handle_matcher'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/memoized_helpers.rb:68:in `should'
# ./spec/controllers/restaurant/orders_controller_spec.rb:46:in `block (3 levels) in <top (required)>'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:114:in `instance_eval'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:114:in `block in run'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_exec'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_eval_with_args'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:247:in `instance_eval_with_args'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/hooks.rb:106:in `block (2 levels) in run'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:179:in `call'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:179:in `run'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_exec'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_eval_with_args'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:247:in `instance_eval_with_args'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/hooks.rb:106:in `block (2 levels) in run'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/hooks.rb:108:in `call'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/hooks.rb:108:in `run'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/hooks.rb:446:in `run_hook'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:340:in `run_around_each_hooks'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:256:in `with_around_each_hooks'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/example.rb:111:in `run'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:390:in `block in run_examples'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:386:in `map'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:386:in `run_examples'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:371:in `run'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:372:in `block in run'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:372:in `map'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/example_group.rb:372:in `run'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/command_line.rb:28:in `map'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/command_line.rb:28:in `block in run'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/reporter.rb:58:in `report'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/command_line.rb:25:in `run'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/runner.rb:80:in `run'
# /usr/local/rvm/gems/ruby-2.1.1/gems/rspec-core-2.14.8/lib/rspec/core/runner.rb:17:in `block in autorun'
When I change this back to params.require the test passes, however, I have scenarios where params can be empty.
The text was updated successfully, but these errors were encountered:
Seems to be another issue for 2.6.0
Following on from my update to #482
When my strong parameters method is defined as follows (using fetch rather than require):
I run into the following failure:
When I change this back to
params.require
the test passes, however, I have scenarios where params can be empty.The text was updated successfully, but these errors were encountered: