Rails设计不会重定向到根路径

时间:2018-05-16 22:46:05

标签: ruby-on-rails validation devise

我的user模型看起来像这样typeuser表中的列,而std仅用于在用户sign_up时获取其他数据。现在当user(type: Student)登录时,设计再次呈现带有消息日志的登录页面成功不会呈现root_path并且在日志中它显示回滚事务但是当我刷新页面然后它呈现给{{1 }}。此问题仅发生在root_path,当我删除type:Student行时,所有内容都运行正常。

现在的问题是为什么会发生这种情况或者如何做到这一点 ?

validates_presence_of :std

设计:: RegistrationsController.rb

class User < ApplicationRecord
  attr_accessor :std
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

  validates_presence_of :type


  validates_presence_of :std , allow_blank: false , if: -> { type == 'Student' },
                         message: 'Student must add grade to continue'


end

1 个答案:

答案 0 :(得分:0)

已解决..我认为它在登录时也验证了List[List[a, b, d], List[a, c, d, f], List[a, b, h]] 所以我刚刚添加了

user(type:Student)

现在它仅在注册时进行验证。

相关问题