# Sending methods after classifying

**URL:** <https://www.ruby-forum.com/t/sending-methods-after-classifying/124511>\
**Category:** Rails\
**Created:** [December 29, 2007, 1:21pm UTC](https://www.ruby-forum.com/t/sending-methods-after-classifying/124511 "2007-12-29T13:21:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Love\_AJAX](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/779978/32.png) [@Love\_AJAX](https://www.ruby-forum.com/u/Love_AJAX)\
**Post date:** [December 29, 2007, 1:21pm UTC](https://www.ruby-forum.com/t/sending-methods-after-classifying/124511/1 "2007-12-29T13:21:49Z")

</div>

The following code gives me an error:  
class\_vars = [‘fruit’,‘cow’,‘coffee’].each do |class\_var|  
“#{class\_var}”.classify.send(:find, 1 + rand(10))  
end

The error message stack:  
LocalJumpError: no block given  
from (irb):34:in `find' from (irb):33:in`each’  
from (irb):33:in `find' from (irb):33:in`send’  
from (irb):33  
from (irb):32:in `each’  
from (irb):32  
from :0

What I am trying to do here is, convert a string to an ActiveRecord  
class and then send a AR method like find to it. But it doesn’t work.  
I have all the classes defined.

Any idea why this is happening?

---

<div class="post-metadata">

**Author:** ![Love\_AJAX](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/779978/32.png) [@Love\_AJAX](https://www.ruby-forum.com/u/Love_AJAX)\
**Post date:** [December 29, 2007, 1:45pm UTC](https://www.ruby-forum.com/t/sending-methods-after-classifying/124511/2 "2007-12-29T13:45:15Z")

</div>

On 29 Dec 2007, at 12:21, Love AJAX wrote:

> ```
> from (irb):33:in `find'
> from (irb):33:in `send'
> from (irb):33
> from (irb):32:in `each'
> from (irb):32
> from :0
> 
> ```
> 
> What I am trying to do here is, convert a string to an ActiveRecord  
> class  
> If you just poke around in the console you’ll see that  
> ‘fruit’.classify #=\> ‘Fruit’  
> That’s a string, not a Class (i.e. classify is just a string  
> transformation that camelcases or whatever is has to do).  
> You can use constantize to actually get the class you’re talking about.

Fred

---

<div class="post-metadata">

**Author:** ![Love\_AJAX](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/779978/32.png) [@Love\_AJAX](https://www.ruby-forum.com/u/Love_AJAX)\
**Post date:** [December 29, 2007, 3:18pm UTC](https://www.ruby-forum.com/t/sending-methods-after-classifying/124511/3 "2007-12-29T15:18:54Z")

</div>

It works. Thanks a lot. I should have tried this one.
