Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Odd method error 'first' #16

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

Odd method error 'first' #16

noonandr opened this issue Oct 20, 2011 · 1 comment

Comments

@noonandr
Copy link

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.

@BoZhuM
Copy link

BoZhuM commented Mar 9, 2012

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants