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 as: :authenticatable to sessions association #24

Merged
merged 2 commits into from
Jun 6, 2018
Merged

Add as: :authenticatable to sessions association #24

merged 2 commits into from
Jun 6, 2018

Conversation

pusewicz
Copy link
Contributor

@pusewicz pusewicz commented Jun 6, 2018

This PR adds the missing as: :authenticatable to the model helper when creating the association.

Without it, the user.passwordless_sessions returns an error as the constructed SQL looks up by user_id instead of authenticatable_id.

Closes #23

require 'test_helper'

class AuthenticatableTest < ActiveSupport::TestCase
test "#passwordless_sessions" do

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

@@ -8,7 +8,7 @@ module ModelHelpers
# field name (e.g. `:email`)
# @param field [string] email submitted by user.
def passwordless_with(field)
has_many :passwordless_sessions, class_name: 'Passwordless::Session'
has_many :passwordless_sessions, class_name: 'Passwordless::Session', as: :authenticatable

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [96/80]

@mikker mikker merged commit 698a71b into mikker:master Jun 6, 2018
@mikker
Copy link
Owner

mikker commented Jun 6, 2018

So great!
💙💚💛💜❤️

@pusewicz pusewicz deleted the fix-sessions-association branch June 6, 2018 07:44
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.

None yet

3 participants