第一次在这里发帖,如果有任何格式/结构错误,请道歉!
我正在使用Devise为我的rails应用程序构建一个自定义注册流程,可以在github上查看:github.com/BDecker19/theLIST(我还将它上传到heroku,它显示了同样的问题.. foundersbloc- thelist.herokuapp.com)
不知怎的,我似乎打破了流程,现在当你尝试创建一个新帐户时,它无法通过验证说电子邮件和密码字段不能为空,即使它们已填写完毕。
由于Devise控制器似乎都是内部的,我无法弄清楚如何诊断问题?我正在使用Wicked在登录后创建多步骤配置文件创建过程,因此在我的应用程序控制器中设置了自定义的after_sign_in_path,但似乎这不会导致问题?我也在使用bootstrap,这可能会产生一些影响?否则,只是不确定它可能是什么......
sign_up之前正在工作,虽然我在重新创建我的仓库以上传到Heroku时愚蠢地删除了我的git历史记录。附上下面的一些相关代码,或者告诉我是否应该添加任何其他信息!
提前非常感谢...
视图/色器件/ new.html.erb
<div class="border-form-div">
<h2>Ok, let's get you started...</h2>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<%= f.email_field :email, :autofocus => true, :placeholder => 'Email address' %>
<%= f.password_field :password, :placeholder => 'Password' %>
<%= f.password_field :password_confirmation, :placeholder => 'Password confirmation' %>
<%= f.submit "Continue to next step",:class=>'btn btn-primary' %>
<% end %>
<%= render "devise/shared/links" %>
</div>
模型/ user.rb
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
attr_accessible :profile_complete, :name, :date_of_birth, :bio
end
*控制器/ application_controller.rb *
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
# root action
def home
end
def after_sign_in_path_for(resource)
if current_user.profile_complete == true
redirect_to root_path
else
user_steps_path
end
end
end
答案 0 :(得分:0)
我拉了你的代码并运行了服务器。您可能会在将来查看日志文件,它会显示用户字段的批量分配错误。
除非你真的需要启动一个带有受保护属性gem的新项目,否则我会删除它。这是向后兼容rails 3的一个步骤,在将现有项目从3升级到4时非常有用。
App适用于我:
删除Gemfile中的protected_attributes
gem 'protected_attributes`
删除用户模型中的attr_accessible调用。一切正常。