Hello, i''m using the very popular attachment_fu plugin, almost everything is awesome. But I spend all day to make attachment_fu update a existing file with no success. I''m doing simple upload where my model product has_one product_image(another model), in this product_image i call has_attachment and everything works fine for new products. But when i try update a product record and his image i get the error: undefined method `uploaded_data='' for #<Product:0x679c664> , i thinking update_attributes doesn''t work in attachment_fu when use associations. Someone can help? My code here: class Product < ActiveRecord::Base has_one :product_image, :dependent => :destroy validates_presence_of :name, :category def uploaded_picture=(picture) # used for create new product_image associated with product self.product_image = ProductImage.new self.product_image.uploaded_data = picture end end class ProductImage < ActiveRecord::Base has_attachment :content_type => :image, :storage => :file_system, :max_size => 500.kilobytes, :resize_to => ''640x480>'', :processor => ''MiniMagick'', :thumbnails => { :thumb => ''50x50>'' }, :path_prefix => "public/images/upload/products" validates_as_attachment belongs_to :product end My controller is default generated by scaffold. My views are multipart and in new.html.erb i had: <%= file_field :uploaded_picture %> , and in edit.html.erb i had: <%= file_field :uploaded_data %> Some can help??? Thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I read some posts about problems with attachment_fu and i think this can be a bug. Someone i have maded this operation using has_one association betewen models? On 22 jan, 22:48, Daniel Lopes <danielvlo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, i''m using the very popular attachment_fu plugin, almost > everything is awesome. > But I spend all day to make attachment_fu update a existing file with > no success. > > I''m doing simple upload where my model product has_one > product_image(another model), in this product_image i call > has_attachment and everything works fine for new products. But when i > try update a product record and his image i get the error: undefined > method `uploaded_data='' for #<Product:0x679c664> , i thinking > update_attributes doesn''t work in attachment_fu when use associations. > > Someone can help? > > My code here: > > class Product < ActiveRecord::Base > has_one :product_image, :dependent => :destroy > validates_presence_of :name, :category > > def uploaded_picture=(picture) # used for create new product_image > associated with product > self.product_image = ProductImage.new > self.product_image.uploaded_data = picture > end > end > > class ProductImage < ActiveRecord::Base > has_attachment :content_type => :image, > :storage => :file_system, > :max_size => 500.kilobytes, > :resize_to => ''640x480>'', > :processor => ''MiniMagick'', > :thumbnails => { :thumb => ''50x50>'' }, > :path_prefix => "public/images/upload/products" > > validates_as_attachment > > belongs_to :product > > end > > My controller is default generated by scaffold. > My views are multipart and in new.html.erb i had: > <%= file_field :uploaded_picture %> > > , and in edit.html.erb i had: > <%= file_field :uploaded_data %> > > Some can help??? Thanks.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Change uploaded_photo to uploaded_data and see if that makes a difference. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I can''t do this, because my new.html.erb is a view for product model and not for product_image, this is the reason for uploaded_picturemethod. And the problem not is when call new but update and uploaded_picture is used only in new. On 22 jan, 23:47, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Change uploaded_photo to uploaded_data and see if that makes a difference.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I think the reason is because updated_data is a method for product_image class, but even i use <%= f.file_field :uploaded_picture %>(field for my virtual atribute uploaded_picture) in my edit view i got errors, but this error: undefined method `content_type'' for "Fotos-132.jpg":String Why can''t find content_type inside attachement_fu? Some one can help? How can i update existing attachment when this file is stored in diferent table and associated with other table? I bought Advanced Rails recipes but the chapter about upload had the same problem. On 23 jan, 01:09, Daniel Lopes <danielvlo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I can''t do this, because my new.html.erb is a view for product model > and not for product_image, this is the reason for uploaded_picture> method. > And the problem not is when call new but update and uploaded_picture > is used only in new. > > On 22 jan, 23:47, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Change uploaded_photo to uploaded_data and see if that makes a difference.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> undefined method `content_type'' for "Fotos-132.jpg":String >Your form isn''t a multipart form. -- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Putz... o my god... shame. thanks for help Ryan. On 23 jan, 01:47, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > undefined method `content_type'' for "Fotos-132.jpg":String > > Your form isn''t a multipart form. > > -- > Ryan Bigghttp://www.frozenplague.net > Feel free to add me to MSN and/or GTalk as this email.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
do you find it working with rails 2 ? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Yes, working with rails 2.0.2 On 24 jan, 07:36, mariek <marek.byt...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> do you find it working with rails 2 ?--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I''ve just installed this plugin and I have problem with using with amazon s3. Urls are created in that way <tt>http(s)://:server/:bucket_name/:table_name/:id/:file</tt> instead of : <tt>http(s)://:bucket_name.:server/:table_name/:id/:file</tt> I can fix it manually in this place but I''m not sure if it will work properly at all. On Jan 26, 7:29 pm, Daniel Lopes <danielvlo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yes, working with rails 2.0.2--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---