title: Rails update related model data in update method
body: <p>I have such code:</p>
  
  <pre><code>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 =&gt; @oil.model.to_s.gsub(/\s+/, "").upcase)
          redirect_to admin_oils_path
        end
      else
        render :layout =&gt; 'admin'
      end
    end
  </code></pre>
  
  <p>but when i run it i get:</p>
  
  <pre><code>undefined method `update_attributes' for #&lt;ActiveRecord::Relation:0x007f7fb4cdc220&gt;
  </code></pre>
  
  <p>and my other_products_cross_lists isn't updated... Also i try update_attribute and get the same error.</p>
  
  <p>What i do wrong?</p>
  
  <p>Also when i run my destroy method </p>
  
  <pre><code>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 =&gt; 'admin'
      end
    end
  </code></pre>
  
  <p>other_products_cross_lists  didn't destroy...</p>
  
  <p>How can i solve this problem?</p>
  
  <p>model:</p>
  
  <pre><code>class Oil &lt; ActiveRecord::Base
    has_many :other_products_cross_lists, :foreign_key =&gt; 'main_id'
  
  class OtherProductsCrossList &lt; ActiveRecord::Base
    belongs_to :oil
  </code></pre>