0

heeey!) I was trying to make a gallery but i get an error on file upload

model gallery.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

model image.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

Help me plzzzz =(((

1 Answers1

0

Make sure table has fields or not .

Gallery :

:avatar_file_name
:avatar_content_type
:avatar_file_size

Image :

:image_file_name
:image_content_type
:image_file_size

Take a look on Paperclip: Attaching Files in Rails

Vik
  • 5,931
  • 3
  • 31
  • 38
  • yep, tables has all fields for paperclip ( – Vik Ewoods Apr 10 '12 at 10:00
  • Can you please let me know exactly what error are you getting ... Not getting any idea into the log that you have given . – Vik Apr 10 '12 at 12:31
  • Can you check the link that in my answer . It worked for me long back . Also check the permission of your attachment directory, directory path , directory existence , it may be the issues . – Vik Apr 10 '12 at 12:49
  • Can you update your issue with that how are you adding the partial _form.html.erb into form ... I want to see how you have added form . – Vik Apr 10 '12 at 13:04
  • Try for single image upload : <% form_for :gallery, :html => { :multipart => true } do |f| %> <%= f.file_field :image%> <% end %> ...and check are you able to upload that one . – Vik Apr 10 '12 at 13:06
  • ActiveRecord::UnknownAttributeError: unknown attribute: image =( and this is my form <%= 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 do |image| %> <%= image.file_field :image, :label => "Child Avatar" %> <% end %> – Vik Ewoods Apr 10 '12 at 13:19