0

塗装モデルを更新しようとすると、上記のタイトルのエラーが発生します。

これが私のペイントコントローラーです

def update 
    @painting = Painting.find(params[:id])
    if @painting.update_attributes(params[:painting])
        redirect_to :action => 'show', :id => @painting
    else
        @paintings = Painting.find(:all)
        render :action => 'edit'
    end
end

これが私のモデルです

class Painting < ActiveRecord::Base
    attr_accessible :gallery_id, :name, :image, :avatar
    belongs_to :gallery
    mount_uploader :avatar, ImageUploader
    has_attached_file :avatar, :default_url =>     "/images/:style/missing.png"
      # , :url  => "/assets/:id/:style/:basename.:extension", :path => ":rails_root/public/assets/:id/:style/:basename.:extension"
    validates_presence_of :name

end

Heres私の絵のフォームの部分

<%= form_for([@gallery,@painting], :html => {:multipart => true}) do |f| %>
    <!-- <#%= form_for @painting, :html => {:multipart => true} do |f| %> -->

      <p>
        <%= f.label :name %><br />
        <%= f.text_field :name %>
      </p>
      <p><%= f.file_field :avatar %></p>

      <p><%= f.submit %></p>
    <% end %>

絵画はギャラリーに属しています。つまり、ギャラリーには絵画が含まれています。PS私もキャリアウェーブを使用しています。

4

1 に答える 1