# Calling a function

**URL:** <https://www.ruby-forum.com/t/calling-a-function/126785>\
**Category:** Rails\
**Created:** [January 22, 2008, 7:15am UTC](https://www.ruby-forum.com/t/calling-a-function/126785 "2008-01-22T07:15:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aaaarg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9bcb4/32.png) [@Aaaarg](https://www.ruby-forum.com/u/Aaaarg)\
**Post date:** [January 22, 2008, 7:15am UTC](https://www.ruby-forum.com/t/calling-a-function/126785/1 "2008-01-22T07:15:50Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Aaaarg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9bcb4/32.png) [@Aaaarg](https://www.ruby-forum.com/u/Aaaarg)\
**Post date:** [January 22, 2008, 7:21am UTC](https://www.ruby-forum.com/t/calling-a-function/126785/2 "2008-01-22T07:21:08Z")

</div>

On line 2, try: def self.store\_description (image)

---

<div class="post-metadata">

**Author:** ![Aaaarg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9bcb4/32.png) [@Aaaarg](https://www.ruby-forum.com/u/Aaaarg)\
**Post date:** [January 22, 2008, 8:26am UTC](https://www.ruby-forum.com/t/calling-a-function/126785/3 "2008-01-22T08:26:39Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Aaaarg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9bcb4/32.png) [@Aaaarg](https://www.ruby-forum.com/u/Aaaarg)\
**Post date:** [January 22, 2008, 11:44am UTC](https://www.ruby-forum.com/t/calling-a-function/126785/4 "2008-01-22T11:44:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Aaaarg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9bcb4/32.png) [@Aaaarg](https://www.ruby-forum.com/u/Aaaarg)\
**Post date:** [January 22, 2008, 2:23pm UTC](https://www.ruby-forum.com/t/calling-a-function/126785/5 "2008-01-22T14:23:27Z")

</div>

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?
