# Problem with forms, Date\_Select and DateBocks

**URL:** <https://www.ruby-forum.com/t/problem-with-forms-date-select-and-datebocks/66716>\
**Category:** Rails\
**Created:** [August 28, 2006, 5:47pm UTC](https://www.ruby-forum.com/t/problem-with-forms-date-select-and-datebocks/66716 "2006-08-28T17:47:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![karen123](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e495f1/32.png) [@karen123](https://www.ruby-forum.com/u/karen123)\
**Post date:** [August 28, 2006, 5:47pm UTC](https://www.ruby-forum.com/t/problem-with-forms-date-select-and-datebocks/66716/1 "2006-08-28T17:47:22Z")

</div>

Please help me - I’m out of ideas.  
I want to create a form that passes various parameters to a Query  
object. I sucessfully passed the parameter called machine\_name BUT I  
can’t pass the parameter called start\_date.  
The code for my form is shown below

* * *

\<% form\_for :query, :url =\> {:action =\> ‘show’} do |form| %\>

```
<p>
    <label for "query_machine_name"> Machine: </label>
    <%= form.select :machine_name,
                    @machines,
                    :prompt => "Select Machine"
    %>
</p>
<p>
    <label for "query_start_date"> Start Date: </label>
    <%=form.date_select(:start_date) %>
</p>

<%=submit_tag "Get Results", :class => "submit"%>

```

## \<%end%\>

Again, machine name is PASSED OK.  
I get no errors but the parameter start\_date isn’t passed. I tried  
substituting the date\_select line for this:

* * *

## \<%=date\_select(:query, :start\_date) %\>

this also did not trigger an error but did not pass start\_date.

Ideally I would like a DateBocks calendar to pop up but I can’t figure  
that out either. I get an error no matter what I put in - I have no idea  
what to do with it. (I have installed the plugin.) I tried all of the  
following (in place of the Date\_Select line) and got the following  
errors

* * *

## \<%=datebocks\_field(:query, :start\_date) %\>

undefined method `+’ for :query:Symbol

* * *

## \<%=form.datebocks\_field(:start\_date) %\>

undefined method `datebocks\_field’ for  
#ActionView::Helpers::FormBuilder:0x378bab0

* * *

## \<%=datebocks\_field(@query[:start\_date], :start\_date) %\>

undefined method `[]’ for #Query:0x3870930

* * *

## \<%=datebocks\_field(:query[:start\_date], :start\_date) %\>

undefined method `[]’ for :query:Symbol

* * *

## \<%=datebocks\_field(@query.start\_date, :start\_date) %\>

You have a nil object when you didn’t expect it!  
You might have expected an instance of Array.  
The error occured while evaluating nil.+

Please someone help -  
(1) What am I doing wrong with Date\_Select?  
(2) What am I doing wrong with DateBocks and how do I associate it with  
the form?

Any help much appreciated.  
Karen

---

<div class="post-metadata">

**Author:** ![karen123](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e495f1/32.png) [@karen123](https://www.ruby-forum.com/u/karen123)\
**Post date:** [August 28, 2006, 9:02pm UTC](https://www.ruby-forum.com/t/problem-with-forms-date-select-and-datebocks/66716/2 "2006-08-28T21:02:12Z")

</div>

At the moment, DateBocks only accepts strings as a Model name.

So in the instance where you have…

\<%=datebocks\_field(:query, :start\_date) %\>

Try using

\<%=datebocks\_field(‘query’, ‘start\_date’) %\>

If Query is the variable containing your model, and start\_date is the  
column.

-NSHB

On 8/28/06, Karen H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> </p>
> 
> ```
> 
> * * *
> 
> * * *
> 
> Any help much appreciated.  
> Karen
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Nathaniel Steven Henry Brown

Open Source Insight - [http://nshb.net](http://nshb.net)  
Open Source Development - [http://inimit.com](http://inimit.com)  
Open Source Training - [http://osevents.com](http://osevents.com)

---

<div class="post-metadata">

**Author:** ![karen123](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e495f1/32.png) [@karen123](https://www.ruby-forum.com/u/karen123)\
**Post date:** [August 29, 2006, 11:37am UTC](https://www.ruby-forum.com/t/problem-with-forms-date-select-and-datebocks/66716/3 "2006-08-29T11:37:34Z")

</div>

Hi Nathaniel,  
Thank you - that worked a treat!  
I also figured out my problem with Date\_Select. The form WAS passing  
start\_date but I wasn’t assigning it correctly in my class.  
Not that it matters - I’m going to use DateBocks instead.  
Thanks again,  
Karen

---

<div class="post-metadata">

**Author:** ![karen123](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e495f1/32.png) [@karen123](https://www.ruby-forum.com/u/karen123)\
**Post date:** [August 29, 2006, 12:46pm UTC](https://www.ruby-forum.com/t/problem-with-forms-date-select-and-datebocks/66716/4 "2006-08-29T12:46:55Z")

</div>

Hey Karen,

I added a enhancement request into the ticket tracker. This should be  
added as it’s intuitive usage of almost all the helper methods in  
Rails.

[http://dev.toolbocks.com/tickets/32](http://dev.toolbocks.com/tickets/32)

Be sweet to hear how you are using Datebocks in your app, and maybe a  
url too? 🙂

-NSHB

On 8/29/06, Dot D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Nathaniel Steven Henry Brown

Open Source Insight - [http://nshb.net](http://nshb.net)  
Open Source Development - [http://inimit.com](http://inimit.com)  
Open Source Training - [http://osevents.com](http://osevents.com)

---

<div class="post-metadata">

**Author:** ![karen123](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e495f1/32.png) [@karen123](https://www.ruby-forum.com/u/karen123)\
**Post date:** [August 30, 2006, 9:26am UTC](https://www.ruby-forum.com/t/problem-with-forms-date-select-and-datebocks/66716/5 "2006-08-30T09:26:30Z")

</div>

Nathaniel B. wrote:

> I added a enhancement request into the ticket tracker. This should be  
> added as it’s intuitive usage of almost all the helper methods in  
> Rails.  
> Be sweet to hear how you are using Datebocks in your app, and maybe a  
> url too? 🙂

Hi Nathaniel,  
Thanks for adding that request.  
I’m using DateBocks in an app I’m developing for a hospital so the  
scientists and technologists can check the performance of treatment  
machines. One thing they will want to look at it how the machines’  
performances vary over time. I am using DateBocks when I give them the  
option to select start and end dates.  
I can’t give you a URL because you can’t access it from outside the  
hospital network - you’ll just have to believe me! :o)  
Karen
