Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

time scaffolding uses datetime_select, stores as time

#2377

In Rails 2.3.2,

script/generate scaffold tester birthday:date favorite_time:time

rake db:migrate

script/server

Then visit http://localhost:3000/testers/.

>

The scaffolding will use datetime_select to represent the time, but won't store the date information. The odd result is that the user is asked for and shown the date, but that information isn't real - it's always 1/1/2000.

Previous versions of Rails also showed and asked for the date when they generated scaffolding for time data, but didn't throw it away. The scaffold generation needs to shift to time_select to match the expectations of the underlying datatype.

Reported by Simon St.Laurent · March 30th, 2009 @ 05:20 PM

State: resolved
Milestone: 3.0.2
Assigned to: José Valim José Valim
Importance: none

Activity

  1. Steve St. Martin
    Steve St. Martin
    • Assigned user set to Ryan Bigg

    verified this behavior still exists on both 2.3.5 and master, this issue is probably not mission critical as scaffolds can be changed easily, please submit a patch. for now can probably as mark incomplete.

    April 16th, 2010 @ 01:01 AM

  2. Ryan Bigg
    Ryan Bigg
    • State changed from new to incomplete

    April 16th, 2010 @ 01:26 AM

  3. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  4. Dan Pickett
    Dan Pickett
    • Tag changed from 2.3.2, datetime, scaffold, time, time_select to 2.3.2, bugmash, datetime, scaffold, time, time_select

    May 9th, 2010 @ 05:45 PM

  5. Jeff Kreeftmeijer
    Jeff Kreeftmeijer

    I've attached a patch that makes sure the scaffold's _form partial uses time_select instead of datetime_select when dealing with time attributes. The first one applies to master and the second one's for 2-3-stable. :)

    May 15th, 2010 @ 09:56 AM

  6. Robert Beekman
    Robert Beekman

    +1

    applies cleanly to master, tests pass.

    May 15th, 2010 @ 01:50 PM

  7. Rizwan Reza
    Rizwan Reza
    • Tag changed from 2.3.2, bugmash, datetime, scaffold, time, time_select to 2.3.2, bugmash, bugmash-review, datetime, scaffold, time, time_select
    • State changed from incomplete to verified

    May 15th, 2010 @ 05:03 PM

  8. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 3.x to 2.3.6
    • State changed from verified to incomplete

    No regression test.

    May 15th, 2010 @ 06:31 PM

  9. Rizwan Reza
    Rizwan Reza
    • Tag changed from 2.3.2, bugmash, bugmash-review, datetime, scaffold, time, time_select to 2.3.2, bugmash, datetime, scaffold, time, time_select

    May 15th, 2010 @ 06:45 PM

  10. Santiago Pastorino
    Santiago Pastorino

    We need to complete test the generation behavior not only the time one.
    Please try to do it.

    May 15th, 2010 @ 08:44 PM

  11. Jeff Kreeftmeijer
    Jeff Kreeftmeijer

    I've attached a patch for master with tests for the Rails::Generators::GeneratedAttribute#field_type method and included my previous patch. What do you think?

    I can this for 2-3-stable as well if you guys like it. :)

    May 15th, 2010 @ 10:10 PM

  12. Santiago Pastorino
    Santiago Pastorino

    Nice Jeff, but you should do all in one patch

    May 15th, 2010 @ 11:49 PM

  13. Jeff Kreeftmeijer
    Jeff Kreeftmeijer

    One patch, or one commit? The last patch has everything in it (but two commits). :)

    May 16th, 2010 @ 12:25 AM

  14. Santiago Pastorino
    Santiago Pastorino
    • State changed from incomplete to open
    • Assigned user changed from Ryan Bigg to José Valim

    one commit only

    May 16th, 2010 @ 01:23 AM

  15. Jeff Kreeftmeijer
    Jeff Kreeftmeijer

    Ok, I squashed the commits in the master patch and added the same one for 2-3-stable. Here we go. :)

    May 16th, 2010 @ 01:31 AM

  16. Santiago Pastorino
    Santiago Pastorino
    • Milestone cleared.
    • State changed from open to verified

    Well done Jeff +1 ;).
    Wait for José to push to master and 2-3-stable.

    May 16th, 2010 @ 01:47 AM

  17. Rizwan Reza
    Rizwan Reza
    • Tag changed from 2.3.2, bugmash, datetime, scaffold, time, time_select to 2.3.2, bugmash-review, datetime, scaffold, time, time_select

    May 16th, 2010 @ 02:07 AM

  18. Repository
    Repository
    • State changed from verified to resolved

    (from [3568c5cee0f37f3302d739472be7477bee1b0d2a]) using :time_select when the attribute type is :time in the scaffold generator. [#2377 state:resolved]

    Signed-off-by: José Valim jose.valim@gmail.com
    http://github.com/rails/rails/commit/3568c5cee0f37f3302d739472be747...

    May 16th, 2010 @ 09:45 AM

  19. Repository
    Repository

    (from [4750e61bfecd210e5c4d96546d638b5cd23bb09e]) using :time_select when the attribute type is :time in the scaffold generator. [#2377 state:resolved]

    Signed-off-by: José Valim jose.valim@gmail.com
    http://github.com/rails/rails/commit/4750e61bfecd210e5c4d96546d638b...

    May 16th, 2010 @ 09:53 AM

  20. José Valim
    José Valim
    • State changed from resolved to open

    Ops, I forgot to apply the patch with tests. I just asked Jeff on #railsbridge to refactor the current tests (using something like assert_attribute_type and remove the code duplication) and provide new patches with only tests!

    May 16th, 2010 @ 10:04 AM

  21. Jeff Kreeftmeijer
    Jeff Kreeftmeijer

    And here they are. I've attached a patch for master adding assert_attribute_type to DRY things up, with the forgotten tests. Also, one for 2-3-stable. :)

    May 16th, 2010 @ 10:53 AM

  22. Repository
    Repository
    • State changed from open to resolved

    (from [5ff6de0982c165bb9038258d867398c73c142084]) Added assert_attribute_type to clean up GeneratedAttributeTest [#2377 state:resolved]

    Signed-off-by: José Valim jose.valim@gmail.com
    http://github.com/rails/rails/commit/5ff6de0982c165bb9038258d867398...

    May 16th, 2010 @ 11:08 AM

  23. Repository
    Repository

    (from [ec017e158a0f006ac30bee94f81411a4d74a5227]) Added assert_attribute_type to clean up GeneratedAttributeTest [#2377 state:resolved]

    Signed-off-by: José Valim jose.valim@gmail.com
    http://github.com/rails/rails/commit/ec017e158a0f006ac30bee94f81411...

    May 16th, 2010 @ 11:10 AM

  24. Rizwan Reza
    Rizwan Reza
    • Tag changed from 2.3.2, bugmash-review, datetime, scaffold, time, time_select to 2.3.2, datetime, scaffold, time, time_select

    May 16th, 2010 @ 03:06 PM

  25. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to

    October 15th, 2010 @ 11:01 PM