Problem with forms, Date_Select and DateBocks

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

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

</p>


Any help much appreciated.
Karen


Posted via http://www.ruby-forum.com/.


Nathaniel Steven Henry Brown

Open Source Insight - http://nshb.net
Open Source Development - http://inimit.com
Open Source Training - http://osevents.com

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

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

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

-NSHB

On 8/29/06, Dot D. [email protected] wrote:

Posted via http://www.ruby-forum.com/.


Nathaniel Steven Henry Brown

Open Source Insight - http://nshb.net
Open Source Development - http://inimit.com
Open Source Training - http://osevents.com

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

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