Hi,
I am still very much a beginner at this - seems pretty neat though!
I have a nice little comments form like so:
Post a comment
<%= form_tag :action => "comment", :id => @post %> Name:<%= text_field "comment", "name" %>
Date:
<%= datetime_select "comment", "created_at" %>
Email: (won't be displayed)
<%= text_field "comment", "email" %>
Website: (include http://)
<%= text_field "comment", "website" %>
Comment:
<%= text_area "comment", "body" %>
<%= submit_tag "Comment!" %>
Now, I don’t really want the user to be able to select a datetime, I’d
rather that it was done serverside, but I’ve no idea how to do that.
I toyed with replacing the datetime_select with a series of
hidden_fields, but that doesn’t seem the right way, and anyway, I
couldn’t work out how to get just the current year, just the day, just
the minute etc. Also, the prepopulated datetime isn’t correct, probably
due to me being in the UK and the server being in the US.
I would rather have the datetime added in the controller I think, is
this the correct way?
def comment
Post.find(params[:id]).comments.create(params[:comment])
flash[:notice] = “Added your comment.”
redirect_to :action => “show”, :id => params[:id]
end
Perhaps it should go in there somewhere…
Any ideas? Does anyone know of a good book/tutorial to get started on
such issues?
Thanks!