Hi. I''m trying to call the function ''store_description(image)'' at line 9. However when I do, I get the error "undefined method ''store_description'' for Photo:Class". What can I do? 1: class Photo < ActiveRecord::Base 2: def store_description (image) 3: self.description = "size: "+number_to_human_size(image.filesize) 4: end 5: file_column :image, :magick => { 6: :versions => { 7: "thumb" => { 8: :transformation => Proc.new { |image| 9: store_description(image) # what do I put here??? 10: image.change_geometry!(''160x120'') { |cols, rows, img| 11: img.thumbnail!(cols, rows) 12: } 13: }, 14: :attributes => { :quality => 50 } 15: } 16: } 17: } 18: end 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 -~----------~----~----~----~------~----~------~--~---
On line 2, try: def self.store_description (image) On Jan 21, 10:04 pm, Aaaarg <Flash.Art...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi. I''m trying to call the function ''store_description(image)'' at line > 9. However when I do, I get the error "undefined method > ''store_description'' for Photo:Class". What can I do? > > 1: class Photo < ActiveRecord::Base > 2: def store_description (image) > 3: self.description = "size: > "+number_to_human_size(image.filesize) > 4: end > 5: file_column :image, :magick => { > 6: :versions => { > 7: "thumb" => { > 8: :transformation => Proc.new { |image| > 9: store_description(image) # what do I put > here??? > 10: image.change_geometry!(''160x120'') { |cols, > rows, img| > 11: img.thumbnail!(cols, rows) > 12: } > 13: }, > 14: :attributes => { :quality => 50 } > 15: } > 16: } > 17: } > 18: end > > 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 -~----------~----~----~----~------~----~------~--~---
Okay, I''ve tried that, and the function runs now (progress!) however I now get the following error: undefined method `number_to_human_size'' for Photo:Class If I eliminate the ''number_to_human_size'' then I get the error: undefined method `description='' for Photo:Class Any ideas? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Let''s try this: Change line 2 to: def store_description (image) Change line 9 to: self.store_description(image) If that doesn''t work, try having them both be self. On Jan 21, 11:25 pm, Aaaarg <Flash.Art...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Okay, I''ve tried that, and the function runs now (progress!) however I > now get the following error: > undefined method `number_to_human_size'' for Photo:Class > > If I eliminate the ''number_to_human_size'' then I get the error: > undefined method `description='' for Photo:Class > > Any ideas?--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Okay, I tried those both. The first suggestion triggers this familiar error: undefined method ''store_description'' for Photo:Class And the second, this one: undefined method `description='' for Photo:Class Surely what I''m trying to do isn''t that odd? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---