1

I am trying to set a multi-form login system using the Wicked gem. I have devise installed up and running correctly, when following these steps:http://railscasts.com/episodes/346-wizard-forms-with-wicked.

I'm not being redirected to the user_step_paths? everything is done as stated in the tutorial but, I'm guessing because I'm using devise i need to do it in a controller inherited by devise? my code is below for the controllers:

users_controller.rb

class UsersController < Devise::RegistrationsController
  def new
    @user = User.new
  end
  def create
      @user = User.new(params[:sign_up])
      if @user.save
        session[:user_id] = @user.id
        redirect_to user_steps_path
      else
        redirect_to new_user_registration_path
      end
  end
end

users_steps_controller.rb

class UserStepsController < ApplicationController

  include Wicked::Wizard
  steps :education, :social

  def show
    render_wizard
  end

end

routes

  get 'pages/home'
  devise_for :users, :controllers => { :registrations => 'users'}  
  resources :user
  resources :user_steps
Gurmukh Singh
  • 1,875
  • 3
  • 24
  • 62
  • can you establish whether the create action is being hit? Try adding "raise 'creating user..'" at the beginning of the create method and see if an error is raised in the browser. If so, take it out and then check if there are any errors when you try and save the user: "raise @user.errors.messages". Put that just before the redirect_to new_user_registration_path line. – Chris Lewis Feb 02 '16 at 13:45
  • When you try to send the sign up form does it log you in? or does it show any error? – svelandiag Feb 02 '16 at 15:23
  • Could you please add your sign up form? I need to check the path the form is sending the data. – svelandiag Feb 02 '16 at 15:25
  • I recommended look at this example at once http://railscasts.com/episodes/217-multistep-forms – Mayur Shah Apr 01 '19 at 17:18

1 Answers1

3

1.Needed a update method in the controller and needed to define user in the show method:

def show
    @user = current_user
    render_wizard
  end

  def update
    @user = current_user
    @user.update_attributes(user_params)
    render_wizard @user
  end

2.Needed to generate the devise controllers:

rails generate devise:controllers [scope]

3.Update the registration_controller for devise

class Users::RegistrationsController < Devise::RegistrationsController
# before_filter :configure_sign_up_params, only: [:create]
# before_filter :configure_account_update_params, only: [:update]

  # GET /resource/sign_up
   def new
     super
   end

  # POST /resource
   def create
     super
   end

  # GET /resource/edit
  # def edit
  #   super
  # end

  # PUT /resource
   def update
     super
   end

# The path used after sign up.
   def after_sign_up_path_for(resource)
     user_steps_path
   end

  # The path used after sign up for inactive accounts.
   def after_inactive_sign_up_path_for(resource)
     super(resource)
   end
end

4.This controller is invalid, you need to use the generated controllers by devise:

class UsersController < Devise::RegistrationsController
Gurmukh Singh
  • 1,875
  • 3
  • 24
  • 62