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
# 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.
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.