datetime_select tag bug? or my fault?

All morning and last night I have had to work with this bug / or my fault in the following :

I wish for the user to select an arrival date (m/d/y); the arrival date is of type datetime.

when I have     Arrives :<%= pu.datetime_select :arrives %>

it gives me the hour and minutes. I can capture the arrival date and see it being displayed in the controller when I do a logger.debug ( ">>> arrives #{@unit.arrives}")

I dont want the user to set the hour and minute though (important) So I type in : Arrives : <%= pu.datetime_select(:arrives, :discard_hour=>true %>

This results in arrival date not being captured; now when I do a logger.debug ( ">>> arrives #{@unit.arrives}") I get nothing.

I have tried various permutations and combinations :discard_minute=>true etc. and it just doesnt seem to work with :discard_hour=>true

What am I doing wrong here?

browse here :

http://railsapi.org/actionview-helpers-datehelper-datetime_select

reinhart http://teapoci.blogspot.com

Rails Terrorist wrote:

browse here :

railsapi.org - railsapi Resources and Information.

reinhart http://teapoci.blogspot.com

What does that mean? Does it mean that datetime does not have a :discard_hour=>true option?

I notice this option here : http://dev.rubyonrails.org/ticket/2089

I even tried this : http://www.methods.co.nz/rails_date_kit/rails_date_kit.html

but that does not work (tried all kinds of permutations/ combinations). Any other usable interfaces/plugins would be cool.

Wait a second that is a similar response you gave to this guy :

I am sure people can READ the apis my friend. This particular version does not mention any discard_hour option either :ActionView::Helpers::DateHelper

However rails way by Obie Fernandez (2008) on page 415 says :

datetime_select(object_name, method, options = {})

Works exactly like date_select, except for the addition of hour and minute select tags. Seconds may be added with the option :include_seconds. Along with the addition of time information come additional discarding options: :discard_hour, :discard_minute, and :discard_seconds.

Calm down Bro, i think you are too hurry to interpret of written in my url :smiley:

I can see your stressful here.

man... you should make it like hashing, you can not use : <%= pu.datetime_select(:arrives, :discard_hour=>true %>

But if you use : <%= pu.datetime_select(:bus, :arrives, :discard_hour=>true %>

It would be working 100%

that is why i gave you :

http://railsapi.org/actionview-helpers-datehelper-datetime_select

Cheer, Reinhart http://teapoci.blogspot.com

calm down bro... you did not read your script carefully :slight_smile: you have made mistake here :

<%= pu.datetime_select (:pso_unit, :arrives ,:discard_hour=>true, :order=>[:month,:day,:year]) %>

The correct script is

<%= datetime_select (:pso_unit, :arrives ,:discard_hour=>true, :order=>[:month,:day,:year]) %>

Dont ask me why. I can answer it, but i need you to find answer of this matter by your self. Because you are impatient programmer and careless :smiley:

Cheer,

Reinhart http://teapoci.blogspot.com

Rails Terrorist wrote:

you have made mistake here :

<%= pu.datetime_select (:pso_unit, :arrives ,:discard_hour=>true, :order=>[:month,:day,:year]) %> The correct script is <%= datetime_select (:pso_unit, :arrives ,:discard_hour=>true, :order=>[:month,:day,:year]) %>

I tried that before I tried pu.datetime_select...

<%= datetime_select(:pso_unit, :arrives, :discard_hour=>true, :default=>DateTime.now, :order=>[:month,:day,:year]) %>

does not work either.

This works :     <%= pu.datetime_select :arrives , :order=>[:month,:day,:year] %>

however the moment I add :discard_hour=>true, I can no longer read the date in the arrives field. I can email the mvc to you. Lastly just a gentle request : would you be nice enough to please not label me as you try to help me , thanks! :slight_smile: appreciate your kindness.

i dont know what is your exactly problem there because i implemented your script with/out pu and I have always been success without error.

You can email me at booking2heaven@yahoo.com or upload it here.

Regards Reinhart

<%= datetime_select(:pso_unit, :arrives, :discard_hour=>true, :default=>DateTime.now, :order=>[:month,:day,:year]) %>

it works here to me

If you dont want user set hour and minutes, why you not only use select_date ?? or a plugin like toolbocks (calendar).

Reinhart

Rails Terrorist wrote:

<%= datetime_select(:pso_unit, :arrives, :discard_hour=>true, :default=>DateTime.now, :order=>[:month,:day,:year]) %>

it works here to me

If you dont want user set hour and minutes, why you not only use select_date ?? or a plugin like toolbocks (calendar).

Reinhart

Ok then there must be something wrong with my environment/setup or application. I could send you the code and the data dump if you wish.

I am not using date as opposed to datetime for extensibility reasons. Thanks for the tip on datetime toolbocks... that is what I was looking for.

Ather Shiraz wrote:

Rails Terrorist wrote:

<%= datetime_select(:pso_unit, :arrives, :discard_hour=>true, :default=>DateTime.now, :order=>[:month,:day,:year]) %>

it works here to me

If you dont want user set hour and minutes, why you not only use select_date ?? or a plugin like toolbocks (calendar).

Reinhart

Ok then there must be something wrong with my environment/setup or application. I could send you the code and the data dump if you wish.

I am not using date as opposed to datetime for extensibility reasons. Thanks for the tip on datetime toolbocks... that is what I was looking for.

BTW the datetime_select is embedded in this form :

<% form_for :pso, :url=> {:action=>:create} do |f| %>

<% fields_for :pso_unit do |pu| %> ... <%= datetime_select(:pso_unit, :arrives, :discard_hour=>true, :default=>DateTime.now, :order=>[:month,:day,:year]) %> <%end>

<%end %>