-4
컨트롤러에 컨트롤러가 있습니다. @ 현재 사용자는 show, new에서 생성되지만 def _params에서 작동하지 않습니다. 예 : @ current_user.role : 에 대해 정의되지 않은 메소드`role ' nil : NilClass. 감사합니다. .Rails current_user nil
def company_params
if @current_user.role.name != 'admin'
params[:company_id] = @current_user.company.id
end
params.require(:company).permit(.........)
end
ERROR : 무기 호에 대한 정의되지 않은 메서드`역할 'NilClass
이 컨트롤러의 코드를 표시 하시겠습니까? –
자세한 정보를 입력하십시오. 또한 [최소, 완전하며 검증 가능한 예제를 만드는 방법] (http://stackoverflow.com/help/mcve)을 참고하십시오. [Tour] (http://stackoverflow.com/tour) 복용을 고려해보십시오. – seong
'@ current_user'는 어디에 정의되어 있습니까? 당신이 Devise를 사용하고 있습니까? – mmichael