因此,我想让我的应用程序注册过程分为两个步骤(最终在将来更多)。但是,我很难让邪恶的使用设计一下。。具体来说,我不确定如何实现正确的控制器代码,给出的控制器是预先构建的。
它应该如何工作,用户填写他们的标准帐户信息,(电子邮件,用户名,通行证,密码确认),然后点击下一步,在第二页,他们填写他们的年龄。
到目前为止,这就是我所拥有的:
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 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乐意提供任何额外的代码,如果有必要,使这一工作!
发布于 2014-11-24 14:11:15
只要先确保注册后,你是重定向到邪恶的第一步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://stackoverflow.com/questions/27106685
复制相似问题