0

heeey!)我试图制作一个画廊,但我在文件上传时遇到错误

模型库.rb

class Gallery < ActiveRecord::Base  
  acts_as_content_block
  has_attached_file :avatar, :styles => { :thumb => "291x191#" }

  #attr_accessible :images
  has_many :images
  accepts_nested_attributes_for :images, :allow_destroy => true
end

模型图像.rb

class Image < ActiveRecord::Base
belongs_to :gallery
#acts_as_content_block :belongs_to_gallery => true
 has_attached_file :image, :styles => { :large => "640x480", :medium => "300x300>", :small => "100x100>" }
end

_form.html.erb

<p> Hello world!</p>

<%= f.cms_text_field :name %>
<%= f.cms_text_area  :description %>
<%= f.cms_file_field :avatar, :label => "Avatar" %>

<% f.object.images.build %>
<%= f.fields_for :images, :html => { :multipart => true } do |image| %>
 <%= image.file_field :image, :label => "Child Avatar" %>
<% end %>

==================================================== ======

Started POST "/cms/galleries/14" for 91.2**.41.*** at 2012-04-10 01:28:14 +0400
  Processing by Cms::GalleriesController#update as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"ziD3527h0JynfX05FcpnVgjsPSz2rGP4MKbEDmOun4U=", "gallery"=>{"lock_version"=>"0", "connect_to_page_id"=>"", "connect_to_container"=>"", "name"=>"Галерея", "description"=>"", "images_attributes"=>{"0"=>{"image"=>#<ActionDispatch::Http::UploadedFile:0x000000047a2570 @original_filename="загруженное.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"gallery[images_attributes][0][image]\"; filename=\"\xD0\xB7\xD0\xB0\xD0\xB3\xD1\x80\xD1\x83\xD0\xB6\xD0\xB5\xD0\xBD\xD0\xBD\xD0\xBE\xD0\xB5.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<File:/tmp/RackMultipart20120410-18330-3iyv20>>}}, "publish_on_save"=>"true"}, "id"=>"14"}
Command :: identify -format %wx%h '/tmp/загруженное.jpg20120410-18330-4sshl[0]'
Command :: convert '/tmp/загруженное.jpg20120410-18330-4sshl[0]' -resize "640x480" '/tmp/загруженное20120410-18330-tfa27r'
Command :: identify -format %wx%h '/tmp/загруженное.jpg20120410-18330-4sshl[0]'
Command :: convert '/tmp/загруженное.jpg20120410-18330-4sshl[0]' -resize "300x300>" '/tmp/загруженное20120410-18330-h8iclv'
Command :: identify -format %wx%h '/tmp/загруженное.jpg20120410-18330-4sshl[0]'
Command :: convert '/tmp/загруженное.jpg20120410-18330-4sshl[0]' -resize "100x100>" '/tmp/загруженное20120410-18330-el6pk'
Redirected to http://*********/cms/galleries/14
Completed 302 Found in 218ms

帮帮我plzzzz =(((

4

1 回答 1

0

确保表有或没有字段。

画廊:

:avatar_file_name
:avatar_content_type
:avatar_file_size

图片 :

:image_file_name
:image_content_type
:image_file_size

看看Paperclip:在 Rails 中附加文件

于 2012-04-10T09:40:34.903 回答