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

Override Registrations Controller - #3430

Closed
jgrannas opened this issue Jan 19, 2015 · 1 comment
Closed

Override Registrations Controller - #3430

jgrannas opened this issue Jan 19, 2015 · 1 comment

Comments

@jgrannas
Copy link

I am trying to override Registrations so that i can have two seperate signup forms. I want to make use of two seperate login and register pages (one normal login/register and a seperate one for my checkout login/register). I am setting a session variable on the checkout/sign_in page.

Right now, if i try to sign in from my checkout/sign_in page and i have validation errors it pushes me back to the default devise sign_in page. Any help is appreciated

Routes

devise_for :users, path: 'account', controllers: { confirmations: 'confirmations', registrations: 'registrations'}
  devise_scope :user do
    patch "/confirm" => "confirmations#confirm"
  end

My override controller. Notice the else if resource does not persist.

class RegistrationsController < Devise::RegistrationsController


  def create
    build_resource(sign_up_params)

    resource.save
    yield resource if block_given?
    if resource.persisted?
      if resource.active_for_authentication?
        set_flash_message :notice, :signed_up if is_flashing_format?
        sign_up(resource_name, resource)
        respond_with resource, location: after_sign_up_path_for(resource)
      else
        set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_flashing_format?
        expire_data_after_sign_in!
        respond_with resource, location: after_inactive_sign_up_path_for(resource)
      end
    else
      #IT SEEMS THIS DOES NOT WORK, EVEN IF I PASS IN THE PROPER LOGIN PATH PATH
      respond_with resource, location: after_sign_up_path_for(resource)
    end
  end

  private

    def after_sign_up_path_for(resource)
      session[:login_url] || root_url
    end


end
@josevalim
Copy link
Contributor

Please use the mailing list or StackOverflow for questions/help, where a wider community will be able to help you. We reserve the issues tracker for issues only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants