# Quick question regarding params

**URL:** <https://www.ruby-forum.com/t/quick-question-regarding-params/91434>\
**Category:** Rails\
**Created:** [April 9, 2007, 4:53am UTC](https://www.ruby-forum.com/t/quick-question-regarding-params/91434 "2007-04-09T04:53:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sshefer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@sshefer](https://www.ruby-forum.com/u/sshefer)\
**Post date:** [April 9, 2007, 4:53am UTC](https://www.ruby-forum.com/t/quick-question-regarding-params/91434/1 "2007-04-09T04:53:49Z")

</div>

Hi,

I currently am using acts as tree for building site navigation. When a  
new page is added to the site, a select option with the include blank  
option gets populated to determine the correct parent for the new  
page. I would like the blank option to be set to 0 for root status.

I tried creating a quick test in the controller to see if the  
params[:parent\_id] is nil and then assigning a 0 to it but it did not  
work. Can anyone offer any help with this?

Thanks!

---

<div class="post-metadata">

**Author:** ![sshefer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@sshefer](https://www.ruby-forum.com/u/sshefer)\
**Post date:** [April 9, 2007, 6:51pm UTC](https://www.ruby-forum.com/t/quick-question-regarding-params/91434/2 "2007-04-09T18:51:05Z")

</div>

Shai S. wrote:

> Hi,
> 
> I currently am using acts as tree for building site navigation. When a  
> new page is added to the site, a select option with the include blank  
> option gets populated to determine the correct parent for the new  
> page. I would like the blank option to be set to 0 for root status.
> 
> I tried creating a quick test in the controller to see if the  
> params[:parent\_id] is nil and then assigning a 0 to it but it did not  
> work. Can anyone offer any help with this?
> 
> Thanks!

You can construct the options yourself, and insert the blank option  
manually with array addition:

f.select :parent\_id, [[’’, 0]] + select\_parent\_options

Where select\_parent\_options is a helper like:

def select\_parent\_options  
Page.find(:all).collect do |p|  
[p.title, p.id]  
end  
end

This makes sure that your blank line returns 0 instead of nil.

---

<div class="post-metadata">

**Author:** ![sshefer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@sshefer](https://www.ruby-forum.com/u/sshefer)\
**Post date:** [April 9, 2007, 7:57pm UTC](https://www.ruby-forum.com/t/quick-question-regarding-params/91434/3 "2007-04-09T19:57:25Z")

</div>

> ```
> end
> 
> ```
> 
> end

Ah ha! Thanks, I was trying this but added the [’’, 0] to the actual  
select helper, this helps a ton!
