0

第一次在这里发帖,如有格式/结构错误,敬请见谅!

我正在为我的 rails 应用程序使用 Devise 构建一个自定义注册流程,可以在 github 上查看:github.com/BDecker19/theLIST(我也将它上传到 heroku,在那里它显示了同样的问题..foundersbloc-thelist.herokuapp .com)

不知何故,我似乎打破了流程,现在当您尝试创建一个新帐户时,验证失败说电子邮件和密码字段不能为空,即使它们已填写。

由于设计控制器似乎都是内部的,我不太清楚如何诊断问题?我正在使用 Wicked 在登录后创建多步配置文件创建过程,因此在我的应用程序控制器中设置了自定义 after_sign_in_path,但似乎这不是导致问题的原因?我也在使用引导程序,这可能会产生一些影响?否则,只是不确定它可能是什么......

sign_up 之前可以正常工作,尽管当我重新创建我的 repo 以上传到 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> 

模型/用户.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
4

1 回答 1

0

我提取了您的代码并运行了服务器。您将来可能会查看日志文件,它会显示用户字段的批量分配错误。

除非您真的需要使用受保护的属性 gem 启动一个新项目,否则我会删除它。这是向后兼容 rails 3 的一步,并且在将现有项目从 3 升级到 4 时最有用。

应用程序适用于我,如果:

删除 Gemfile 中的 protected_attributes

gem 'protected_attributes`

删除用户模型中的 attr_accessible 调用。一切正常。

于 2013-09-16T17:14:28.413 回答