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

NoMethodError: undefined method `unscoped' for Class #82

Closed
antulik opened this issue Dec 2, 2015 · 2 comments
Closed

NoMethodError: undefined method `unscoped' for Class #82

antulik opened this issue Dec 2, 2015 · 2 comments
Assignees

Comments

@antulik
Copy link

@antulik antulik commented Dec 2, 2015

locate_many does not work properly when different objects are passed.

GlobalID::Locator.locate_many ['gid://app/User/3', 'gid://app/Custom::Item/74592']

The issue User is active_record model and responds to :unscoped, Custom::Item is custom model and does not support :unscoped method.

As a result the above code returns
NoMethodError: undefined method 'unscoped' for Custom::Item:Class

but works if you swap the order of objects.

Related
https://github.com/rails/globalid/pull/73/files

@antulik

This comment has been minimized.

Copy link
Author

@antulik antulik commented Dec 2, 2015

as a workaround who needs it, I've added this class method to Custom::Item class

def self.unscoped
  if block_given?
    yield
  else
    self
  end
end
@kaspth

This comment has been minimized.

Copy link
Member

@kaspth kaspth commented Jan 6, 2016

Thanks @antulik. 2d4bc2d should fix your issue 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.