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

Extract Registrations Controller logic out to overrideable methods ??? #1143

Closed
Marinlemaignan opened this issue Apr 12, 2018 · 1 comment
Closed

Comments

@Marinlemaignan
Copy link
Contributor

Hello there,
I'm facing issues in my code right now because of some lack of flexibility in some methods, for exemple, #create in RegistrationsController (i am implementing some rather complicated login logic with scopes all the way through some STI)
My idea would be to extract the resource's initialization code out to an overrideable method
(a bit like when you had moved out those methds to the ResourceFinder Concern which super super useful !)

      @resource = resource_class.new(sign_up_params.except(:confirm_success_url))
      @resource.provider   = provider

      # honor devise configuration for case_insensitive_keys
      if resource_class.case_insensitive_keys.include?(:email)
        @resource.email = sign_up_params[:email].try :downcase
      else
        @resource.email = sign_up_params[:email]
      end

should become something like :

build_registration_resource

which would then set the resource:

def build_registration_resource
    @resource = resource_class.new(sign_up_params.except(:confirm_success_url))
      @resource.provider   = provider

      # honor devise configuration for case_insensitive_keys
      if resource_class.case_insensitive_keys.include?(:email)
        @resource.email = sign_up_params[:email].try :downcase
      else
        @resource.email = sign_up_params[:email]
      end
end

What do you think about that, could that be something you'd be up for? or just a bad idea?

@Marinlemaignan
Copy link
Contributor Author

here's the PR : #1144

MaicolBen pushed a commit that referenced this issue Apr 23, 2018
…hod (#1144)

#1143 extract @resource initialization out to a named overrideable method in registrations controller
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