0

我正在使用 Carrierwave & Fog 将图像 str8 推送到 S3。

创建操作工作得很好。问题是每当我去更新记录,比如更改name属性,并且我不对图像字段做任何事情时,我都会收到如下所示的错误:

Started PUT "/vendors/7" for 67.230.41.62 at 2012-12-09 07:00:51 +0000
2012-12-09T07:00:51+00:00 app[web.1]:   app/controllers/vendors_controller.rb:65:in `update'
2012-12-09T07:00:51+00:00 app[web.1]: NoMethodError (undefined method `thumb_image_changed?' for #<Vendor:0x00000005940750>):
2012-12-09T07:00:51+00:00 app[web.1]: 
2012-12-09T07:00:51+00:00 app[web.1]:   app/controllers/vendors_controller.rb:66:in `block in update'

VendorsController#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

结尾

违规行是update_attributes.

这是我的views/vendors/_form.html.erb

<%= simple_form_for(@vendor) do |f| %>
  <%= f.error_notification %>

  <div class="form-inputs">
    <div class="span8">
        <%= f.input :name, :label => "Vendor Name", :wrapper_html => { :class => "span6" } %>
    </div>
    <div class="span8">
        <%= f.input :intro_text, :label => "The headline for your storefront", :as => :text, :wrapper_html => { :class => "span6" }, :input_html => { :rows => 1 } %>
    </div>    
    <div class="span8">
        <%= f.input :description, :label => "The description of your store", :as => :text, :wrapper_html => { :class => "span6" }, :input_html => { :rows => 5 } %>
    </div>
    <div class="span8">
        <%= f.input :banner_image, :label => "Upload Banner", :wrapper_html => { :class => "span6" } %>    
    </div>
    <div class="span8">
        <%= f.input :logo_image, :label => "Upload Logo", :wrapper_html => { :class => "span6" } %>    
    </div>
    <div class="span8">
        <%= f.button :submit, :class => "btn", :wrapper_html => { :class => "span6" } %>
    </div>
  </div> <!-- /.form-inputs -->


<% end %>

对于它的价值,我的图像尺寸之一image_uploader.rbthumb

  version :thumb, :from_version => :main_banner do
    process :resize_to_limit => [170, 120]
  end

关于如何解决这个问题的想法?

编辑 1

Vendor型号:

class Vendor < ActiveRecord::Base
  attr_accessible :name, :description, :banner_image, :logo_image, :intro_text, :thumb_image
    mount_uploader :banner_image, ImageUploader
    mount_uploader :logo_image, ImageUploader
    mount_uploader :thumb_image, ImageUploader

    acts_as_tagger

    has_many :products

    def tags
        self.owned_tags
    end

    def taggings
        self.owned_taggings
    end
end

编辑 2

我的Vendor表的架构如下所示:

  create_table "vendors", :force => true do |t|
    t.string   "name"
    t.text     "description",  :limit => 255
    t.datetime "created_at",                  :null => false
    t.datetime "updated_at",                  :null => false
    t.string   "banner_image"
    t.string   "logo_image"
    t.string   "intro_text"
  end
4

1 回答 1

0

结果我不得不删除mount_uploader :thumb_image我的Vendor模型上的调用,因为我没有thumb_image在那个模型上调用列。

于 2013-01-13T22:21:12.730 回答