Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hashie 3.3.0 breaks parameters #738

Closed
erkattak opened this issue Aug 26, 2014 · 2 comments
Closed

hashie 3.3.0 breaks parameters #738

erkattak opened this issue Aug 26, 2014 · 2 comments

Comments

@erkattak
Copy link

I'm using grape from the master branch (currently 0.8.1)

hashie was updated to 3.3.0 along with my update to rails 4.1.5

This has caused issues with parameter validations, since the validators access the parameters with whatever symbol/string was used to define that attribute (seemingly).

So, when I have parameters such as

{ 
  'property_id' => 1
  # ...
}

When the validations are being run, the PresenceValidator access this attribute like so:

unless params.respond_to?(:key?) && params.key?(attr_name)

This causes any "requires" validations to fail all the time.

I think this belongs in hashie, but wanted to make a note here for anyone else that might have this issue

vagrant ☆ :/vagrant$ irb
irb(main):001:0> gem 'hashie', '3.3.0'
=> true
irb(main):002:0> require 'hashie'
=> true
irb(main):003:0> m = Hashie::Mash.new 'property_id' => 1
=> #<Hashie::Mash property_id=1>
irb(main):004:0> m['property_id']
=> 1
irb(main):005:0> m[:property_id]
=> nil
irb(main):006:0> m.property_id
=> 1
irb(main):007:0> exit
vagrant ☆ :/vagrant$ irb
irb(main):001:0> gem 'hashie', '3.2.0'
=> true
irb(main):002:0> require 'hashie'
=> true
irb(main):003:0> m = Hashie::Mash.new 'property_id' => 1
=> #<Hashie::Mash property_id=1>
irb(main):004:0> m['property_id']
=> 1
irb(main):005:0> m[:property_id]
=> 1
irb(main):006:0> m.property_id
=> 1
@dblock
Copy link
Member

dblock commented Aug 26, 2014

There's a fix PRed in Grape in #737.

@dblock
Copy link
Member

dblock commented Aug 26, 2014

I've yanked Hashie 3.3.0, reverted hashie/hashie#197 which is the root cause of this, in hashie/hashie#217, and cut 3.3.1. Things should be back to normal now.

@dblock dblock closed this as completed Aug 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants