Problem with multi step sign up

I’m have been struggling with this for a while, so I’m really hoping for your help :slight_smile:

I’m new to programming and rails.

I’ve tried to create a multi step sign up form for my website. I’m using devise for authentication, cancancan for authorization and wicked wizard for the multi step sign up form.

Iv’e got two steps (company and profile) after the email and password sign up.
Currently the sign up is working for the first step. When I fill out email and password and click next step, I get redirected to the first step in my multi signup form (company). When I fill out the field on the company sign up page and click next, it should send me to the last sign up page (profile). Instead I get this error.

If I click on the ’Skip step button’ it’s working fine, and I get to the last step ’profile’.

registration_steps_controller.rb

class RegistrationStepsController < ApplicationController

include Wicked::Wizard

steps :company, :profile


def show

@user = current_user

render_wizard

end


def update

@user = current_user

@user.attributes(user_params)

render_wizard @user

end


private

def user_params

params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation, :phone)

end


end

registrations_controller.rb

class Users::RegistrationsController < Devise::RegistrationsController

protected


def after_sign_up_path_for(resource)

registration_steps_path

end

def after_update_path_for(resource)

registration_steps_path

end


end

routes.rb

Rails.application.routes.draw do

mount RailsAdmin::Engine => ‘/admin’, as: ‘rails_admin’

devise_for :users, controllers: {:registrations => “users/registrations”}

resources :registration_steps


root ‘pages#index’

get ‘about’, to: ‘pages#about’

get ‘team’, to: ‘pages#team’

get ‘faqs’, to: ‘pages#faqs’

get ‘faqspractitioners’, to: ‘pages#faqspractitioners’

get ‘faqsusers’, to: ‘pages#faqsusers’

get ‘login’, to: ‘pages#login’

get ‘signup’, to: ‘pages#signup’

get ‘search’, to: ‘pages#search’

end

company.html.erb

<%= link_to ‘skip’, next_wizard_path %>

<%= form_for @user, url: wizard_path, method: :put do |f| %>

<%= f.label :phone %>

<%= f.text_field :phone, autofocus: true, autocomplete: “Tlf. nummer” %>

<%= f.submit “Save and Next” %> # will move to the next page

<% end %>

profile.html.erb

<%= link_to ‘skip’, next_wizard_path %>

<%= form_for @user, url: wizard_path, method: :put do |f| %>

<%= f.label :last_name %>

<%= f.text_field :last_name, autofocus: true, autocomplete: “Efternavn” %>

<%= f.submit “Save and Next” %> # will move to the next page

<% end %>

Any help would be much appreciated :slight_smile:

Try change update method

def update
  @user = current_user
  # Change @user.attributes(user_params) by @user.update_attributes(user_params)
  @user.update_attributes(user_params)
  render_wizard @user
end

You just saved my day, it works :slight_smile: Thank you very much for your help :slight_smile:

1 Like