Hello, I am using attachment_fu to handle my images. i get an error message "cant convert nil into string" when updating a person if i do not specify the image for the person. Does anyone know whats wrong. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Just stating the obvious: if you don''t supply a file then attachment_fu chokes on the uploaded_data being nil. From a broader perspective it sounds like you may have included the images as part of the Person model. You''re better off restructuring the images into their own model. If only Person will have images then use a has_one/has_many and belongs_to relationship to associate them. If you''ll have several models that need images then use a polymorphic association (Photo belongs_to :photographable, :polymorphic=>true and Person has_many :photos, :as=>:photographable). By doing that you can test for the presence of an uploaded image and only create the Photo model if one was supplied. One word of warning -- avoid naming the model Image. Long story short, the RESTful image_path causes some issues by aliasing a controller method. HTH, AndyV On Feb 9, 9:07 am, Ank Ag <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hello, > I am using attachment_fu to handle my images. > i get an error message "cant convert nil into string" when updating a > person if i do not specify the image for the person. > Does anyone know whats wrong. > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
AndyV wrote:> Just stating the obvious: if you don''t supply a file then > attachment_fu chokes on the uploaded_data being nil. > > From a broader perspective it sounds like you may have included the > images as part of the Person model. You''re better off restructuring > the images into their own model. If only Person will have images then > use a has_one/has_many and belongs_to relationship to associate them. > If you''ll have several models that need images then use a polymorphic > association (Photo belongs_to :photographable, :polymorphic=>true and > Person has_many :photos, :as=>:photographable). By doing that you can > test for the presence of an uploaded image and only create the Photo > model if one was supplied. > > One word of warning -- avoid naming the model Image. Long story > short, the RESTful image_path causes some issues by aliasing a > controller method. > > > HTH, > AndyVHello, Thanks for the information I will try that out. I need photos for multiple models. Can you please explain me or give me some link to understand the polymorphic association. Is it correc that I will need to have a photographable_id in the photo table. Thank you. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---