nuby - about date_select, getting into DB

Hello Everyone,

I am trying to use the date_select() form helper method per AWDWROR.
In
the DB the column "entry_date" is a datetime.

So using the below form, in part

============ app/views/entry/index.rhtml ===
<tr> <th>date</th><td><%= date_select("entry_date", :start) %></td>
</tr>

how do I get it into the AR instance?

============ app/controllers/EntryController.rb =======
def create
    @entry = Entry.new(
                       :entry_date => params[:entry_date]["start"],
                       :task_id => params[:task][:id],
                       :description => params[:description]
                      );
end

This gives me "entry_date cannot be null" from mysql.

The backtrace/debug dump on the error page mentioned that
Parameters: ....
"entry_date"=>{"start(1i)"=>"2007", "start(2i)"=>"4",
"start(3i)"=>"25"}

where did that (1i), (2i) stuff come from? what does it mean?

In any case I was hoping to use a DHTML calendar pop-up for this date
entry, but wanted to get this working for the prototype. So if you
can
help I appeciate it

thanks
Sam

# ----- View

<h1>Editing book</h1>

<%= error_messages_for :book %>

<% form_for(:book, :url => book_path(@book), :html => { :method
=> :put }) do |f| %>
  <p>
    <b>Created at</b><br />
    <%= f.datetime_select :created_at %>
  </p>

  <p>
    <b>Title</b><br />
    <%= f.text_field :title %>
  </p>
...
...
...
  <p>
    <%= submit_tag "Update" %>
  </p>
<% end %>

<%= link_to 'Show', book_path(@book) %> |
<%= link_to 'Back', books_path %>

# ---- Controller

  # POST /books
  # POST /books.xml
  def create
    @book = Book.new(params[:book])

    respond_to do |format|
      if @book.save
        flash[:notice] = 'Book was successfully created.'
        format.html { redirect_to book_url(@book) }
        format.xml { head :created, :location => book_url(@book) }
      else
        format.html { render :action => "new" }
        format.xml { render :xml => @book.errors.to_xml }
      end
    end
  end

P.S. If you would prefer to let Rails completely handle the entry_date
for you just change the name of the column in the DB to created_at
(for datetime) or created_on (for date). Then you can remove the
date_select entirely from the form and Rails will automatically set
the field to the current date and time when the record is created.
You can also use updated_on and updated_at to create auto updating
date and time stamps.

Thanks - maybe I should state the bigger picture of what I am trying
to do - its basically an event logger. Really this is pretty simple
but I am new at Ruby and Rails so life is hard now.

So users can choose a date on which the event occurred, that is taken
care of my the date_select field (for now)

then they need to choose a start and end time within that date. So for
this I am using text fields because its easier for them to type. But
in the DB I would like to save these as timestamp fields because there
is going to be a lot of reporting and statistics that goes on based on
the data.

So in the DB I have

Any pointers? how would the seasoned pro go about this?

Well, a seasoned pro would likely use a JavaScript/DHTML date and time
picker with all the fancy bells and whistles. Then use it's resulting
date string representation to parse into a Ruby Time object. That is
if they choose not to use the build in date time selectors Rails
provides.

well I was going to use a DHTML timepicker widget but thought
prototyping with this would be easier. But I have since found out, not
so much.

my current creation looks like this for the curious:
http://pastecode.com/28881