When an allowed ActionController::Parameters object was given as an argument, an empty array was returned. I wanted to get the data even with the parameters.
Even if the argument is ActionController::Parameters object, records will be searched correctly.
# in rails
class Country < ActiveHash::Base
self.data = [
{:id => 1, :name => "US"},
{:id => 2, :name => "Canada"}
]
end
Country.where(name: 'US').to_a
#=> [#<Country:0x0000... @attributes={:id=>1, :name=>"US"}>]
params = ActionController::Parameters.new(name: 'US')
# before
Country.where(params.permit!).to_a
#=> []
# after
Country.where(params.permit!).to_a
#=> [#<Country:0x0000... @attributes={:id=>1, :name=>"US"}>]
Country.where(params).to_a
#=> ActiveHash::ForbiddenAttributesError
Tell me if insufficient testing.
And ActiveHash::Relation#where also raise an ArgumentError when an unexpected object is passed as an argument.
# before
Country.where([:id, 'US'])
#=> NoMethodError (undefined method `keys' for [:name, "US"]:Array)
# after
Country.where([:id, 'US'])
#=> ArgumentError (Unsupported argument type: [:name, "US"] (Array))
When an allowed
ActionController::Parameters
object was given as an argument, an empty array was returned. I wanted to get the data even with the parameters. Even if the argument isActionController::Parameters
object, records will be searched correctly.Tell me if insufficient testing.
And
ActiveHash::Relation#where
also raise anArgumentError
when an unexpected object is passed as an argument.Thanks.