NoHandlerError关于轨道上的红宝石的Paperclip 3.2.1

时间:2012-04-28 16:21:14

标签: ruby ruby-on-rails-3 paperclip

我正在尝试使用回形针上传多张图片。我正在学习本教程:http://www.emersonlackey.com/article/paperclip-with-rails-3

不幸的是我有错误:

No handler found for "apple_mac-1280x800.jpg"

Asset.rb

class Asset < ActiveRecord::Base
  belongs_to :post
  has_attached_file :asset, :styles => { :small => "100x100", :original => '800x600>'}
end

Post.rb

class Post < ActiveRecord::Base
  has_many :assets
  accepts_nested_attributes_for :assets, :allow_destroy => true
end

Posts_controller.rb

def new
    @post = Post.new
    5.times { @post.assets.build }

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @post }
    end
end

def edit
  @post = Post.find(params[:id])
  5.times { @post.assets.build }
end

@Post表格

<% create_url = {:url=>{:action=>"create"}} if @post.new_record? %>
    <% form_for @post, :html => {:multipart => true}  do |t| %>
      <p>
        <%= t.label :title, 'Virsraksts:' %>
        <%= t.text_field :title %>
      </p>
      <p>
        <%= t.label :content, 'Teksts:' %>
        <%= t.text_area :content, :class => "mceEditor"%>
      </p>

      <%= t.fields_for :assets do |asset_fields| %>
         <% if asset_fields.object.new_record? %>
            <p>
                <%= asset_fields.file_field :asset %>
            </p>
         <% end %>
      <% end %>


      <%= t.submit %>
    <% end %>
<%end%>
通过更改

问题解决了

<%= t.fields_for :assets do |asset_fields| %>

<%= f.fields_for :assets do |asset_fields| %>

但有人可以解释原因吗?

0 个答案:

没有答案