레일을 사용하고 있습니다. 5.1.4 create, new에서 다른 클래스의 인스턴트 클래스 객체에 액세스 할 수 없습니다.레일 5 User.find (params [: user_id]) nill
예 : User.find(params[:user_id])
은 users_controller
에만 적용됩니다. 동일한 테이블에 5 가지 유형의 사용자가 있습니다. 한 점에서 나는이
class User < ApplicationRecord
after_create :assign_default_role
mount_uploader :avatars, AvatarsUploader
# :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.jpg",
def assign_default_role
self.add_role(:user) if self.roles.blank?
end
belongs_to :lawfirm
has_many :mycases
has_many :mycasecomments
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
end
가 지금은에
다른 컨트롤러 말 User.find(params[:attorney_user_id])
에 액세스 할 수 없습니다 생각했다.
도와주세요.
User.find (params [: attorney_user_id])를 호출 할 때 반환되는 특정 오류를 보여줄 수 있습니까? – Cyzanfar
'params [: attorney_user_id]'가 실제로 설정 되었는가, 그 값은 무엇입니까? 컨트롤러 메소드는 어떻게 보이나요? 레일 4와 5로 질문을 태그했는데 실제로 사용하는 버전은 무엇입니까? – spickermann