Ruby on rails 使用Device with Desive(2步注册流程)
因此,我想让我的申请注册过程分两步进行(最终在将来会进行更多)。然而,我在工作上遇到了麻烦。具体地说,我不确定如何实现正确的控制器代码,因为Desive的控制器是预先构建的 其工作原理是,用户填写他们的标准帐户信息(电子邮件、用户名、通行证、密码确认),然后单击“下一步”,并在第二页填写他们的年龄 这就是我到目前为止所做的: RegistrationController.rb(设计控制器)Ruby on rails 使用Device with Desive(2步注册流程),ruby-on-rails,ruby-on-rails-4,devise,Ruby On Rails,Ruby On Rails 4,Devise,因此,我想让我的申请注册过程分两步进行(最终在将来会进行更多)。然而,我在工作上遇到了麻烦。具体地说,我不确定如何实现正确的控制器代码,因为Desive的控制器是预先构建的 其工作原理是,用户填写他们的标准帐户信息(电子邮件、用户名、通行证、密码确认),然后单击“下一步”,并在第二页填写他们的年龄 这就是我到目前为止所做的: RegistrationController.rb(设计控制器) 很高兴提供任何额外的代码,如果必要的话,让这个工作 只需确保注册后首先重定向到wicked的第一步url即
很高兴提供任何额外的代码,如果必要的话,让这个工作 只需确保注册后首先重定向到wicked的第一步url即可
class RegistrationsController < Devise::RegistrationsController
protected
def after_sign_up_path_for(resource)
'your_wicked_first_step_path'
end
end
参考资料:
class UserStepsController < ApplicationController
include Wicked::Wizard
steps :add_age
def show
render_wizard
end
def update
render_wizard
end
end
<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>
<%= form_for @user, url: wizard_path do |f| %>
<%= f.age :age %>
<%= f.submit "Add Age" %>
<% end %>
resources :user_steps
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" }