myObject.send( from Agile Development book

I’m studying the Agile Development with Rails book. In the chapter that
first sets up the depot application (page 68), there is this bit of code
from a view:

<% for product in @products %>

<% for column in Product.content_columns %> <%=h product.send( %> <% end %> etc...

I am trying to absorb both Ruby and rails as fast as I can. So I am
searching both the Ruby API and the Rails API for methods that I don’t
know. When I lookup “send” in the rails API, I don’t find anything.
When I
look it up in the Ruby API, it says that the form is obj.send(symbol
[,args…]). Well, there is no symbol in use here. So I am confused
the “send”.

Then, I can’t find a method “name” anywhere. Unlike “human_name”, it is
listed as one of the methods of a Column in active record. At least I
find it.

I know what this code accomplishes, but I wish I understood it better.

Can anyone point me in the right direction?

I suggest that you use script/console and irb to find stuff that isn’t
in the

First go to the directory of your rails app, and do the following:

[email protected]:/opt/www/mart$ script/console
Loading development environment.

=> “product_category_id”

=> “reference”

=> String

=> ["==", “===”, “=~”, “id”, “send”, “`”, “b64encode”, “blank?”,
“class”, “clone”, “dclone”, “decode64”, “decode_b”, “default”,
“dup”, “encode64”, “eql?”, “equal?”, “extend”, “freeze”, “frozen?”,
“human_name”, “id”, “inspect”, “instance_eval”, “instance_of?”,
“instance_variable_get”, “instance_variable_set”, “instance_variables”,
“is_a?”, “kind_of?”, “klass”, “limit”, “load”, “method”, “methods”,
“nil?”, “null”, “number?”, “object_id”, “primary”, “primary=”,
“private_methods”, “protected_methods”, “public_methods”,
“remove_subclasses_of”, “require”, “require_gem”,
“require_library_or_gem”, “respond_to?”, “returning”, “send”,
“silence_stderr”, “silence_warnings”, “singleton_methods”,
“suppress”, “taguri”, “taguri=”, “taint”, “tainted?”, “text?”, “to_a”,
“to_s”, “to_yaml”, “to_yaml_properties”, “to_yaml_style”, “type”,
“type_cast”, “type_cast_code”, “untaint”]

So there’s a ‘name’ method which gives you the name of the column.

[email protected]:/opt/www/mart$ irb
irb(main):001:0> 5.send(:+, 4)
=> 9
irb(main):002:0> 5.send("+", 4)
=> 9

5 is an object, that has a method “+” and accept another object to add
Looks like ‘send’ method accepts either a symbol like :+ or a string “+”
name the method.

Good luck,


You found the right send method. The first argument to send is the
name of the method that you’d like to invoke, followed by any
arguments needed by the method.

Regarding name, it is an attribute of Column, as is default, limit, etc.

In the case of the depot app, that would be product.

Disregard the last sentence below. It was extraneous.

I had started to say "in the case of the depot app the names of the
methods would be product.title, product.description, etc.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs