Vendor
これは、モデルのレコードの非画像属性を更新しようとしたときに発生するエラーです(例:) owner
。
NoMethodError at /admin/vendor/12/edit
Message undefined method `thumb_image_changed?' for #<Vendor:0x007ff47d097468>
File /.rvm/gems/ruby-1.9.3-p194@my-app/gems/activemodel-3.2.8/lib/active_model/attribute_methods.rb
Line 407
そのため、画像を変更していなくても、このエラーが発生します。
これは私のVendor
モデルがどのように見えるかです:
class Vendor < ActiveRecord::Base
attr_accessible :name, :description, :banner_image, :logo_image, :intro_text, :thumb_image, :category_ids, :product_ids, :user_id, :remove_banner_image, :banner_image_cache, :remove_logo_image, :logo_image_cache
mount_uploader :banner_image, ImageUploader
mount_uploader :logo_image, ImageUploader
mount_uploader :thumb_image, ImageUploader
has_many :products, :dependent => :destroy
has_many :categories, :through => :products
belongs_to :owner, :class_name => "User",
:foreign_key => "user_id"
end
レコードの画像の1つだけを更新しようとすると(3つすべてではない)、同様のエラーが発生すると思います。
これを引き起こしている可能性があり、どうすれば修正できますか?
ありがとう。
編集1:
コントローラは、通常は足場のアクションのVendor#update
ように見えます。update
def update
@vendor = Vendor.find(params[:id])
respond_to do |format|
if @vendor.update_attributes(params[:vendor])
format.html { redirect_to @vendor, notice: 'Vendor was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @vendor.errors, status: :unprocessable_entity }
end
end
end
このリクエストを生成するパラメータは次のとおりです。
Started PUT "/vendors/12" for 127.0.0.1 at 2013-01-06 16:51:28 -0500
Processing by VendorsController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"3bl5Q=", "vendor"=>{"name"=>"Die", "intro_text"=>"Toppa top jeans", "description"=>"The best jeans you can get your legs in."}, "commit"=>"Update Vendor", "id"=>"12"}
Category Load (13.0ms) SELECT "categories".* FROM "categories" LIMIT 6
Vendor Load (0.1ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = ? LIMIT 1 [["id", "12"]]
(0.1ms) begin transaction
(0.1ms) rollback transaction
Completed 500 Internal Server Error in 51ms
この場合に更新していた属性はname
属性です。
また、その価値については、このリクエストの完全なスタックトレースを次に示します。