사용 레일레일 3.1 엽기 액티브 동작에서
def create
@practice = Practice.new(params[:practice])
respond_to do |format|
if (current_user.practices << @practice rescue false)
pmf = current_user.practices_users.inspect # if this line is removed the following update_attributes method breaks!
current_user.practices_users.last.update_attributes(:admin_flg => true, :first_name => params[:first_name], :last_name => params[:last_name])
format.html { redirect_to home_dashboard_path, notice: 'Practice was successfully created.' }
format.json { render json: @practice, status: :created, location: @practice }
else
format.html { render action: "new" }
format.json { render json: @practice.errors, status: :unprocessable_entity }
end
end
end
3.1.0 'PMF = ...'라인이 존재하지 않을 때, 나는이 줄을 얻을 만들기 작업을
NoMethodError:
undefined method `update_attributes' for nil:NilClass
때 'pmf = ...'행이 있으면 작성 조치가 정상적으로 작동합니다. 무슨 일 이니?
'pmf ='줄이 없을 때'current_user.practices_users'의 크기는 얼마입니까? 거래가 완료되지 않았을 수도 있습니다 –
"방법 중단"이라고 말하면 어떻게됩니까? 오류 메시지가 무엇입니까? – CharlieMezak