What are options used for?


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

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 :slight_smile:

if parent_id.nil?
link_to “Create link”, :action => :create
link_to “Create link”, :action => :create, :id => parent_id

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.

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 :smiley:



I fixed #1 just with, weird it works now.
link_to “Create page”, { :action => :create, :id => parent_id }

Jamal S. wrote:


I fixed #1 just with, weird it works now.
link_to “Create page”, { :action => :create, :id => parent_id }

I meant to say #2, sorry :slight_smile:

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. [email protected]