2014-11-24 3 views
2

그래서, 신청서 신청 절차를 두 단계 (그리고 앞으로는 더 많은 단계)로 만들고 싶습니다. 그러나 을 Devise.과 함께 사용하는 데 문제가 있습니다. 특히 Devise의 컨트롤러가 미리 빌드 된 경우 올바른 컨트롤러 코드를 구현하는 방법에 대해 확실하지 않습니다.Devick과 Wicked 사용하기 (2 단계 가입 절차)

사용자는 표준 계정 정보 (이메일, 사용자 이름, 패스, 암호 확인)를 채운 후 다음을 클릭하고 두 번째 페이지에서는 나이를 채 웁니다.

RegistrationController.rb (고안 컨트롤러)

class RegistrationsController < Devise::RegistrationsController 
    def new 
    super 
    end 

    def create 
    super 
    end 

    protected 

    def users_steps_path(resource) 
    '/user_steps' 
    end 
end 

UserStepsController.rb (사악한 컨트롤러)

class UserStepsController < ApplicationController 
    include Wicked::Wizard 
    steps :add_age 

    def show 
    render_wizard 
    end 

    def update 
    render_wizard 
    end 
end 

첫째 :

내가 지금까지 무엇을 가지고 step, devise/registrations/new.html.erb

<div class="styled email-input2"> 
    <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> 
    <%= devise_error_messages! %> 
    <div><%= f.email_field :email, autofocus: true, placeholder: "Email", class: "email-input" %></div> 
    <div><%= f.text_field :username, autofocus: true, placeholder: "Username", class: "email-input" %></div> 
    <div><%= f.password_field :password, autocomplete: "off", placeholder: "Password", class: "email-input" %></div> 
    <div><%= f.password_field :password_confirmation, autocomplete: "off", placeholder: "Password confirmation", class: "email-input" %></div> 
</div> 
    <div class="get_motivated2"> 
    <%= f.submit "Sign up", class: "sign-up btn-danger" %> 
<% end %> 
</div> 
</div> 

두 번째 단계, add_age.html.erb

<%= form_for @user, url: wizard_path do |f| %> 
    <%= f.age :age %> 
    <%= f.submit "Add Age" %> 
<% end %> 

Routes.rb

resources :user_steps 

필요한 경우이 작업을 얻기 위해 추가 코드를 제공하는 해피!

답변

2

가입 후 첫 번째 단계 URL로 리디렉션됩니다.

class RegistrationsController < Devise::RegistrationsController 
    protected 

    def after_sign_up_path_for(resource) 
    'your_wicked_first_step_path' 
    end 
end 

이 컨트롤러를 등록 기관 :

devise_for :users, :controllers => { :registrations => "registrations" } 

참조 : https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-on-successful-sign-up-%28registration%29

+0

이 솔루션은 큰 일! –