-
RSS Links
Categories
Archives
Blogroll
Tag Archives: helpers
Rails Helper to Remove Leading Zero in 12 Hour Time Format
I can’t find a strftime() format that will output the hour without the leading zero. For instance 6:20 will be instead 06:20. This just looks a little sloppy. I created a datetime.rb intializer which will contain custom datetime formats for my application.
# RAILS_ROOT/config/initializers/datetime.rb
Time::DATE_FORMATS[:date] = "%a %b %d, %Y"
Time::DATE_FORMATS[:time] = "%I:%M%p"
# ...
Next I set up [...]
Posted in Ruby on Rails Also tagged 12 hour time, datetime, initializers, leading zero, strftime 1 Comment
Date and Time Helpers in Rails
Just for reference http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#M001695
This post was created about ago
Make Rails Lib Module Methods Available to Views
If you create a module in the lib/ directory of your Rails application you won’t have access to those methods in your views. If you don’t want to put those methods in a helper file, you need to add a method to your module that makes them available for you views like so…
#in lib/my_module_name.rb
module [...]
Rails Prototype JS and TinyMCE Autosave
TinyMCE is a nice little WYSIWYG for text processing online. It uses iFrames and Javascript callbacks to manipulate textarea form fields. Using it with Rails can be somewhat problematic if you want to set up an observer on a field that TinyMCE is managing. The reason is that TinyMCE uses an iFrame and a callback [...]
Posted in Programming, Ruby on Rails Also tagged autosave, periodical, prototype, Rails Leave a comment
Yield a Block within Rails Helper Method with Multiple Content_tags Using Concat