# What are options used for?

**URL:** <https://www.ruby-forum.com/t/what-are-options-used-for/112947>\
**Category:** Rails\
**Created:** [August 24, 2007, 9:51pm UTC](https://www.ruby-forum.com/t/what-are-options-used-for/112947 "2007-08-24T21:51:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/35a633/32.png) [@jamal](https://www.ruby-forum.com/u/jamal)\
**Post date:** [August 24, 2007, 9:51pm UTC](https://www.ruby-forum.com/t/what-are-options-used-for/112947/1 "2007-08-24T21:51:43Z")

</div>

Hello,

I actually have few simple questions which I cannot find a answer for in  
the documentation?

1#  
In most of the methods in rails I find the parameter options={} which I  
don’t know what it can include? Can somebody explain this one to me  
please 🙂

2#  
if parent\_id.nil?  
link\_to “Create link”, :action =\> :create  
else  
link\_to “Create link”, :action =\> :create, :id =\> parent\_id  
end

Can’t I do this by DRY? I cannot figure out how to add the if in the  
link\_to so when parent\_id is nil it doesn’t throw exception about that.

3#  
Why do I recieve exception when I type this while using the act\_as\_tree

@pages = Page.find( :all, :conditions =\> ‘parent\_id IS NULL’, :include  
=\> :children)

* * *

I hope someone can help me through some of them, so I can keep working  
on my little project, and thanks in advance for any help 😃

//Jamal

---

<div class="post-metadata">

**Author:** ![jamal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/35a633/32.png) [@jamal](https://www.ruby-forum.com/u/jamal)\
**Post date:** [August 24, 2007, 10:29pm UTC](https://www.ruby-forum.com/t/what-are-options-used-for/112947/2 "2007-08-24T22:29:46Z")

</div>

#1

I fixed #1 just with, weird it works now.  
link\_to “Create page”, { :action =\> :create, :id =\> parent\_id }

---

<div class="post-metadata">

**Author:** ![jamal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/35a633/32.png) [@jamal](https://www.ruby-forum.com/u/jamal)\
**Post date:** [August 24, 2007, 10:30pm UTC](https://www.ruby-forum.com/t/what-are-options-used-for/112947/3 "2007-08-24T22:30:05Z")

</div>

Jamal S. wrote:

> #1
> 
> I fixed #1 just with, weird it works now.  
> link\_to “Create page”, { :action =\> :create, :id =\> parent\_id }

I meant to say #2, sorry 🙂

---

<div class="post-metadata">

**Author:** ![jamal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/35a633/32.png) [@jamal](https://www.ruby-forum.com/u/jamal)\
**Post date:** [August 25, 2007, 7:38pm UTC](https://www.ruby-forum.com/t/what-are-options-used-for/112947/4 "2007-08-25T19:38:59Z")

</div>

Hi jamal,

your 2nd problem got solved b’coz, you combined :id and :actions as  
one object(meaning one parameter to link\_to, so second parameter to  
link to is options, which  
is a hash like structure, where you can pass all your arguements), if  
you don’t put those flower brace, it won’t work b’coz it  
assumes, :action as second argument  
and :id as third argument(which is html\_options, nothing but all the  
possible html tag attributes like id, name, style, class etc…).

And in your 3rd question, can you please show what exception it  
throws, and what does :include =\> :children mean.  
Are you sure, is there any standard argument to find with :children as  
the value of :include key?

On Aug 25, 1:30 am, Jamal S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
