In Rails 3, is there a way to use datetime_select and display hours showing 12 hour am/pm options rather than 24-hour options?
相关问题
- Eager-loading association count with Arel (Rails 3
- Rails simple model attributes not saved to databas
- jquery-ui progressbar not showing
- PDF attachment in email is called 'Noname'
- Is it possible to use redirect_to when it's ca
相关文章
- “No explicit conversion of Symbol into String” for
- Rspec controller error expecting <“index”> but
- Factory_girl has_one relation with validates_prese
- Rails: Twitter Bootstrap Buttons when visited get
- is there a “rails” way to redirect if mobile brows
- Got ActiveRecord::AssociationTypeMismatch on model
- superclass mismatch for class CommentsController (
- rails 3, how add a simple confirmation dialog when
In case anyone stumbles upon this question, the answer for rails 3.2 is:
Here's the method I added to my helper class:
Then I plugged that method into my view:
It seemed to do the trick, but if there's a more idiomatic way of doing this, I'd be interested to hear.
(update: fixed bugs found by thucydides)
The code below treats midnight and noon incorrectly: it calls noon '12 AM,' which is midnight; it calls midnight '12 PM,' which is noon.
Also, the code should use 0:00 as midnight, which is the international standard.
Fixed: