Odd method error 'first' #16

Open
noonandr opened this Issue Oct 20, 2011 · 1 comment

2 participants

@noonandr

I'm getting an odd error when trying to create multiple sized images during upload

undefined method `first' for #<ActionDispatch::Http::UploadedFile:0x105993990>

The code is basically the advanced option in the readme:

class Item
  include Mongoid::Document
  field :name
  embeds_many :images

end
class Image
  include Mongoid::Document
  include Mongoid::Paperclip

  embedded_in :item, :inverse_of => :images

  has_mongoid_attached_file :art,
      :path           => ':id/:style.:extension',
      :storage        => :s3,
      :url            => 'https://s3.amazonaws.com/',
      :bucket => 'buket',
      :s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
      :styles => {
           :original => ['1920x1680>', :jpg],
           :small    => ['100x100#',   :jpg],
           :medium   => ['250x250',    :jpg],
           :large    => ['500x500>',   :jpg]
         }
end

Any ideas what I may be doing wrong? Thanks.

@suffering

I have a similar problem with yours. The first you need to use accepts_nested_attributes_for :images.
You can also consider this solution: has_many :images, autosave: true,accepts_nested_attributes_for :images, and belongs_to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment