# Date\_select

**URL:** <https://www.ruby-forum.com/t/date-select/182511>\
**Category:** Rails\
**Created:** [January 29, 2010, 5:53am UTC](https://www.ruby-forum.com/t/date-select/182511 "2010-01-29T05:53:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![smit\_shah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/87869e/32.png) [@smit\_shah](https://www.ruby-forum.com/u/smit_shah)\
**Post date:** [January 29, 2010, 5:53am UTC](https://www.ruby-forum.com/t/date-select/182511/1 "2010-01-29T05:53:34Z")

</div>

Hi all  
I am using rails 2.3.5. But I am facing the problem with date\_select  
tag. I have written code as follow.

= date\_select :post, :birthdate, :start\_year =\> 1950, :end\_year =\>  
Date.today.year, :prompt =\> { :day =\> ‘Select day’, :month =\> ‘Select  
month’, :year =\> ‘Select year’ }

But I got error like “wrong number of arguments (2 for 1)”. If I write  
only  
= date\_select :post, :birthdate  
than also I got the same error.

I have tried like  
date\_select :post  
than it gives me error like “wrong number of arguments (1 for 2)”.

Help me out…

---

<div class="post-metadata">

**Author:** ![smit\_shah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/87869e/32.png) [@smit\_shah](https://www.ruby-forum.com/u/smit_shah)\
**Post date:** [January 29, 2010, 6:44am UTC](https://www.ruby-forum.com/t/date-select/182511/2 "2010-01-29T06:44:00Z")

</div>

On Fri, 2010-01-29 at 05:53 +0100, Smit S. wrote:

> = date\_select :post, :birthdate  
> than also I got the same error.
> 
> I have tried like  
> date\_select :post  
> than it gives me error like “wrong number of arguments (1 for 2)”.
> 
> Help me out…

* * *

> **[ActionView::Helpers::DateHelper](https://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#M001698)**
>
> Action View Date Helpers The Date Helper primarily creates select/option tags for different kinds of dates and times or date and time elements.

date\_select(object\_name, method, options = {}, html\_options = {})

I don’t think you are going to have any success without the parens

Craig

–  
This message has been scanned for viruses and  
dangerous content by MailScanner, and is  
believed to be clean.

---

<div class="post-metadata">

**Author:** ![smit\_shah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/87869e/32.png) [@smit\_shah](https://www.ruby-forum.com/u/smit_shah)\
**Post date:** [January 29, 2010, 8:58am UTC](https://www.ruby-forum.com/t/date-select/182511/3 "2010-01-29T08:58:02Z")

</div>

Without knowing more about your app and your models, I would ask what  
the :post refers to in your date\_select.

If I understand you correctly, you want to render a date select field  
for the ‘birthdate’ attribute. What model does this attribute belong  
to? Are you using the date\_select as part of a form? If so could you  
post that entire form?

Without further info, I’d say get rid of the ‘:post’ in the  
date\_select. And go from there.

-Alexis M.

---

<div class="post-metadata">

**Author:** ![smit\_shah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/87869e/32.png) [@smit\_shah](https://www.ruby-forum.com/u/smit_shah)\
**Post date:** [January 29, 2010, 11:26am UTC](https://www.ruby-forum.com/t/date-select/182511/4 "2010-01-29T11:26:01Z")

</div>

Alexis Mueller wrote:

> Without knowing more about your app and your models, I would ask what  
> the :post refers to in your date\_select.
> 
> If I understand you correctly, you want to render a date select field  
> for the ‘birthdate’ attribute. What model does this attribute belong  
> to? Are you using the date\_select as part of a form? If so could you  
> post that entire form?
> 
> Without further info, I’d say get rid of the ‘:post’ in the  
> date\_select. And go from there.
> 
> -Alexis M.

Thanks for your reply…

:post is my object and the :birthdate is my field in table. With the  
help of :post I am able to generate field name like post[birthdate]. I  
cant remove that because I am using multi model in a single form.
