내가 같은 코드를 가지고 : 나는 또한 ...레일 업데이트 방법에 갱신 관련 모델 데이터
undefined method `update_attributes' for #<ActiveRecord::Relation:0x007f7fb4cdc220>
을 내 other_products_cross_lists가 업데이트되지 않습니다
def update
@oil = Oil.find(params[:id])
@product_types = ProductType.all
if @oil.update_attributes(params[:oil])
if @oil.other_products_cross_lists.update_attributes(:cross_value => @oil.model.to_s.gsub(/\s+/, "").upcase)
redirect_to admin_oils_path
end
else
render :layout => 'admin'
end
end
을하지만 난 그것을 실행할 때 내가 얻을 update_attribute를 시도하고 같은 오류가 발생합니다.
내가 뭘 잘못 했니? 내가 실행할 때
또한 내
def destroy
@oil = Oil.find(params[:id])
if @oil.destroy
if @oil.other_products_cross_lists.destroy
redirect_to admin_oils_path
end
else
render :layout => 'admin'
end
end
other_products_cross_lists 파괴하지 않은 방법 ...
가 어떻게이 문제를 해결할 수 파괴?모델 :
class Oil < ActiveRecord::Base
has_many :other_products_cross_lists, :foreign_key => 'main_id'
class OtherProductsCrossList < ActiveRecord::Base
belongs_to :oil
'오일'의 모델 정의를 게시 할 수 있습니까? –
@MartinM 추가 한 –