前提・実現したいこと
Deviseを使ってユーザー認証を行おうとしています。
ユーザーモデル名(m_user)、モデル名(m_company)でアソシエーションを行うと、下記のエラーが表示されユーザー登録ができません。
現在、m_userテーブルには、m_company_idというカラムを作成しています。
error
1ja.activerecord.errors.models.m_user.attributes.m_company.required
試したこと
アソシエーションを外すと登録ができました。
ソースコード
#m_company.rb class MCompany < ApplicationRecord has_many :m_users end
#m_user.rb class MUser < ApplicationRecord belongs_to :m_company # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :confirmable, :lockable, :timeoutable, :trackable end
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/04/16 04:00