# Page object

**URL:** <https://www.ruby-forum.com/t/page-object/169186>\
**Category:** Rails\
**Created:** [May 31, 2009, 4:31am UTC](https://www.ruby-forum.com/t/page-object/169186 "2009-05-31T04:31:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ed655f/32.png) [@matthew](https://www.ruby-forum.com/u/matthew)\
**Post date:** [May 31, 2009, 4:31am UTC](https://www.ruby-forum.com/t/page-object/169186/1 "2009-05-31T04:31:14Z")

</div>

Hello,

I’m new to the group, and still learning rails. I am a C++ programmer  
by trade, so I’m finding some of the rails semantics confusing. When I  
come accross a statement like this:

\<%= link\_to\_function “clickme” do |page| …

… and then a few lines that I do understand, could someone explain  
to me the following: the link\_to\_function function takes some object  
for the rendered link, and then what? it’s supposed to be \*args, and  
then &block. I assume that the code that comes afterward is the  
reference to a block of text, but how does the args part work? Also,  
in this instance, how does the do evaluate |page|? and last: where in  
the rails API docs is the reference for the page object?

I’m sure someone well versed in ruby can explain this to me. Thankyou  
for any help. Even links to documentation that explains these ruby  
operators would help. Thanks again,

Matt

---

<div class="post-metadata">

**Author:** ![matthew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ed655f/32.png) [@matthew](https://www.ruby-forum.com/u/matthew)\
**Post date:** [May 31, 2009, 4:37am UTC](https://www.ruby-forum.com/t/page-object/169186/2 "2009-05-31T04:37:42Z")

</div>

On May 31, 1:41 am, Matt S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> for the rendered link, and then what? it’s supposed to be \*args, and  
> then &block. I assume that the code that comes afterward is the  
> reference to a block of text, but how does the args part work? Also,  
> in this instance, how does the do evaluate |page|? and last: where in  
> the rails API docs is the reference for the page object?

\*args means that you can pass it as many arguments as you want (and if  
you were writing such a function then args would be an array  
containing those options). That doesn’t necessarily mean that the  
function will do something sensible if you pass it 23 arguments (to  
know that you need to read the docs for it)

&block is basically just the block you give the function (and the fact  
that it’s there in the docs is probably a bit of an artefact of rdoc -  
you can pass a block to any method (again, no guarantees on what that  
method will do with it). The ‘do’ doesn’t evaluate page, that’s just  
you giving a name to the object that link\_to\_function yields to you  
(which is an instance of JavaScriptGenerator or something similar).

You might find it easier to get a solid grounding in ruby first before  
starting to fiddle around with rails.

Fred

---

<div class="post-metadata">

**Author:** ![matthew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ed655f/32.png) [@matthew](https://www.ruby-forum.com/u/matthew)\
**Post date:** [May 31, 2009, 9:43am UTC](https://www.ruby-forum.com/t/page-object/169186/3 "2009-05-31T09:43:26Z")

</div>

2009/5/31 Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > \<%= link\_to\_function “clickme” do |page| …  
> > you were writing such a function then args would be an array
> 
> You might find it easier to get a solid grounding in ruby first before  
> starting to fiddle around with rails.

I would not say that is necessary to get a ‘solid’ grounding in Ruby  
before fiddling with Rails. I successfully got going with my  
fiddling, learning both at the same time. (Though I continue to make  
errors in both areas of course). The book Agile Web D. with  
Rails (you want the 3rd edition) does a good job of introducing rails  
to those without prior knowledge of Ruby.

Colin
