注册“下一步”按钮未将我重定向到第二种形式
你好,我很难理解为什么下一个按钮不转到下一页。路径单独工作,但在每个路径中,当我填写字段并单击“下一步”时,它不会转到下一个路径。它实际上什么都不做。这里是控制器:
class Users::RegistrationsController < Devise::RegistrationsController
def personal_info
@user = User.new
render 'devise/registrations/personal_info'
end
def create_personal_info
@user = User.new(personal_info_params)
if @user.valid?(:personal_info)
session[:user] = @user.attributes
if @user.save
redirect_to new_user_registration_photo_path
else
render 'devise/registrations/personal_info'
end
else
render 'devise/registrations/personal_info'
end
end
def photo
@user = User.new
render 'devise/registrations/photo'
end
def create_photo
@user = User.new(photo_params)
if @user.valid?(:photo)
session[:user].merge!(@user.attributes)
if @user.save
redirect_to new_user_registration_account_details_path
else
render 'devise/registrations/photo'
end
else
render 'devise/registrations/photo'
end
end
def account_details
@user = User.new
render 'devise/registrations/account_details'
end
def create_account_details
@user = User.new(account_details_params)
if @user.valid?(:account_details)
@user.attributes = session[:user]
if @user.save
session[:user] = nil
sign_in(@user)
redirect_to root_path
else
render 'devise/registrations/account_details'
end
else
render 'devise/registrations/account_details'
end
end
private
def personal_info_params
params.require(:user).permit(:name, :surname, :email, :phone, :birthday, :password, :password_confirmation)
end
def photo_params
params.require(:user).permit(:photo)
end
def account_details_params
params.require(:user).permit(:interests, :skillset, language_skills: [])
end
end
这里是第一个视图
<%= form_for(@user, url: create_user_registration_personal_info_path) do |f| %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.label :email %>
<%= f.email_field :email %>
<%= f.label :password %>
<%= f.password_field :password %>
<%= f.label :password_confirmation %>
<%= f.password_field :password_confirmation %>
<%= f.submit 'Next' %>
<% end %>
路线如下
devise_for :users, controllers: {
registrations: 'users/registrations'
}
devise_scope :user do
get '/sign_up/personal_info', to: 'users/registrations#personal_info', as: :new_user_registration_personal_info
post '/sign_up/personal_info', to: 'users/registrations#create_personal_info', as: :create_user_registration_personal_info
get '/sign_up/photo', to: 'users/registrations#photo', as: :new_user_registration_photo
post '/sign_up/photo', to: 'users/registrations#create_photo', as: :create_user_registration_photo
get '/sign_up/account_details', to: 'users/registrations#account_details', as: :new_user_registration_account_details
post '/sign_up/account_details', to: 'users/registrations#create_account_details', as: :create_user_registration_account_details
end
1条答案
按热度按时间ercv8c1e1#
在personal_info_params中指向的User模型中是否有其他这些强制参数?
在视图中,您只传递了name、email、password、password_confirmation,我的假设是模型User希望这些参数存在