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 dependency is too relaxed #15

Open
leonelgalan opened this issue Aug 1, 2017 · 11 comments
Open

Hashie dependency is too relaxed #15

leonelgalan opened this issue Aug 1, 2017 · 11 comments

Comments

@leonelgalan
Copy link

leonelgalan commented Aug 1, 2017

7cfc2e1 introduced changes that are only supported by hashie >= 3.5.1, when hashie/logger was added:

require "hashie/logger"

That commit is supposed to silence those warnings, but I'm on instagram-continued (1.3.3) and hashie (3.5.6) and I'm still getting them:

> instagram_client.user_recent_media
You are setting a key that conflicts with a built-in method Hashie::Mash#count defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
...
@icco
Copy link
Owner

icco commented Sep 7, 2017

Sorry about that, I'll tighten it up.

@icco
Copy link
Owner

icco commented Sep 7, 2017

Release 1.4.0 to fix this.

@icco icco closed this as completed Sep 7, 2017
@revyd
Copy link

revyd commented Sep 19, 2017

I'm still getting this error even after updating to 1.4.0

@icco
Copy link
Owner

icco commented Sep 19, 2017

@revyd you are? could you provide a minimal test case for it? I'm not getting it anymore.

@revyd
Copy link

revyd commented Sep 19, 2017

The error I'm getting in the console:
You are setting a key that conflicts with a built-in method Hashie::Mash#count defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.

The code in my view
<% @instagram.each_slice(6) do |row| %> <div class="row"> <!-- Each row of my Grid --> <% row.each do |instagram| %> <!-- Each item in my grids row --> <div class='two columns textCenter'> <%= link_to image_tag(instagram.images.thumbnail.url), instagram.images.standard_resolution.url, class: 'fancybox' %> <p class='caption'><%= instagram.caption.text %></p> </div> <% end %> </div> <% end %>
I'm setting @Instagram as:
@instagram = Instagram.user_recent_media("226828041", {count: 12})
I'm pretty sure the error is being raised in the controller statement.
As others have pointed out it's not causing any issue except in logs.

@leonelgalan
Copy link
Author

leonelgalan commented Nov 28, 2017

Same here, calling Hashie.logger = Logger.new(IO::NULL) or Hashie.logger = Logger.new(nil) myself before instantiating the client removes the warning.

$ bundle show instagram-continued
/Users/leonelgalan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/instagram-continued-1.4.0
$ bundle exec rails c
> instagram_access_token = '28...ec'
# => "28...ec"
> Instagram.client(access_token: instagram_access_token).user_recent_media
# You are setting a key that conflicts with a built-in method Hashie::Mash#count defined in Enumerable. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
# ...
# => #<Hashie::Array  ...

@icco icco reopened this Nov 28, 2017
@icco
Copy link
Owner

icco commented Nov 28, 2017

I have no idea how to fix this. We are explicitly setting the hashie logger to NULL. Would love to fix this, but someone will have to send a PR for it to get fixed.

@zhu1230
Copy link

zhu1230 commented Jan 13, 2018

Hi, @icco Just made a PR #17 for this matter. Could you please have a review?
Thanks!

@hossamhossny
Copy link

@zhu1230 I still get

WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#count defined in Enumerable. This can cause unexpected behavior when accessing the key as a property. You can still access the key via the #[] method. specifically when I do a User.recent_media with your PR applied.

@zhu1230
Copy link

zhu1230 commented Jan 16, 2018

Hi, @hossamhossny
It's strange. we use user_recent_media everyday, since then we haven't got the warning anymore.
if possible, could you please let me know how to replicate it?

@hossamhossny
Copy link

I might be very confused as I require instagram_api_client in my code which is another gem that says that it uses InstagramApi and so I assumed it this gem with your patch applied. https://github.com/agilie/instagram_api_gem

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

5 participants