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

add namespaced entity support #113

Conversation

jessesanford
Copy link

When using namespaced models you need to make sure to chop off the namespace portion of the entity class name before you can evaluate it into method names. I know that you are currently refactoring to use the Entity class making the code below much cleaner. This code can be reduced to a single line in the entity.name function there.

@ivan-kolmychek
Copy link

Thank you very much, exactly the problem I've encountered. I hope, it will be approved as soon as possible. =)

@@ -17,8 +17,9 @@ module ActsAsTokenAuthenticationHandlerMethods
end

def authenticate_entity!(entity_class)
entity_underscored = entity_class.name.split("::").last.singularize.underscore

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about 'last' - this can cause problems when there is two models with same name in different namespaces. Maybe, it's better to do .join('_') instead?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi both, I also think so.

Since you both use those namespaces in the wild, can you take a look at a few possible solutions? I propose that once defined something reasonable from anyone point of view we implement it (that should not be a problem). Does that sound fair to you?

Ivan Kolmychek notifications@github.com wrote:

In lib/simple_token_authentication/acts_as_token_authentication_handler.rb:

@@ -17,8 +17,9 @@ module ActsAsTokenAuthenticationHandlerMethods > end > > def authenticate_entity!(entity_class) > + entity_underscored = entity_class.name.split("::").last.singularize.underscore

I am not sure about 'last' - this can cause problems when there is two models with same name in different namespaces. Maybe, it's better to do .join('_') instead?


Reply to this email directly or view it on GitHub.

{"@context":"http://schema.org","@type":"EmailMessage","description":"View this Pull Request on GitHub","action":{"@type":"ViewAction","url":"https://github.com/gonzalo-bulnes/simple_token_authentication/pull/113/files#r18331558","name":"View Pull Request"}}

@gonzalo-bulnes
Copy link
Owner

I forgot to mention that in my opinion, in order to keep the conversation easy to follow, it woul be good to discuss in the original issue (#83). Thanks to both for your comments!

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

Successfully merging this pull request may close these issues.

3 participants