# Child calls

**URL:** <https://www.ruby-forum.com/t/child-calls/94485>\
**Category:** Rails\
**Created:** [May 4, 2006, 6:23pm UTC](https://www.ruby-forum.com/t/child-calls/94485 "2006-05-04T18:23:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![james](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@james](https://www.ruby-forum.com/u/james)\
**Post date:** [May 4, 2006, 6:23pm UTC](https://www.ruby-forum.com/t/child-calls/94485/1 "2006-05-04T18:23:53Z")

</div>

If I use \<%= parent.name %\> and or \<%= parent.child.name %\> then i get  
the correct record.

BUT if say \<% nameholder = “parent.child.name” %\>  
\<%= nameholder %\> it just prints parent.child.name.

How do I get ruby to recognize nameholder as object?

Thanks,

James

---

<div class="post-metadata">

**Author:** ![james](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@james](https://www.ruby-forum.com/u/james)\
**Post date:** [May 4, 2006, 6:24pm UTC](https://www.ruby-forum.com/t/child-calls/94485/2 "2006-05-04T18:24:46Z")

</div>

Don’t quote parent.child.name.

\<% nameholder = parent.child.name %\>

---

<div class="post-metadata">

**Author:** ![james](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@james](https://www.ruby-forum.com/u/james)\
**Post date:** [May 4, 2006, 6:32pm UTC](https://www.ruby-forum.com/t/child-calls/94485/3 "2006-05-04T18:32:24Z")

</div>

Adam B. wrote:

> Don’t quote parent.child.name.
> 
> \<% nameholder = parent.child.name %\>

Thanks for the quick response.

\<% nameholder = “parent.child.name” %\> The quotes are actually from some  
other logic where I am parsing a string in order to create the correct  
parent.child.name… in other words Im creating it dynamically but how  
do I change it back to a command from a string.

Obviously Im a newbie, but I appreciate your help/patience.

James

---

<div class="post-metadata">

**Author:** ![james](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@james](https://www.ruby-forum.com/u/james)\
**Post date:** [May 4, 2006, 7:03pm UTC](https://www.ruby-forum.com/t/child-calls/94485/4 "2006-05-04T19:03:15Z")

</div>

You’re trying to execute a method named by the result of  
parent.child.name?

You could try…

\<% nameholder = eval(parent.child.name.to\_s) %\>

-henry

---

<div class="post-metadata">

**Author:** ![james](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@james](https://www.ruby-forum.com/u/james)\
**Post date:** [May 4, 2006, 6:44pm UTC](https://www.ruby-forum.com/t/child-calls/94485/5 "2006-05-04T18:44:12Z")

</div>

I don’t think that’s possible. However, I KNOW it’s possible to  
dynamically create code. My suggestion is you post your code block that  
creates that string, and wait for someone with more Ruby knowledge than  
I to help you convert it into working Ruby.

-Adam

---

<div class="post-metadata">

**Author:** ![james](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@james](https://www.ruby-forum.com/u/james)\
**Post date:** [May 4, 2006, 7:09pm UTC](https://www.ruby-forum.com/t/child-calls/94485/6 "2006-05-04T19:09:11Z")

</div>

Henry T. wrote:

> You’re trying to execute a method named by the result of  
> parent.child.name?
> 
> You could try…
> 
> \<% nameholder = eval(parent.child.name.to\_s) %\>
> 
> -henry

I love you.

Thanks That was it!
