
Untitled
By: a guest on
May 16th, 2012 | syntax:
None | size: 0.73 KB | hits: 10 | expires: Never
## date_madness.rb (in my lib folder)
module DateMadness
def month_name(month_number)
if month_number
Date::MONTHNAMES[month_number]
end
end
def month_number(month_name)
month_name.downcase
case month_name
when 'january' : puts 1
when 'february' : puts 2
when 'march' : puts 3
when 'april' : puts 4
when 'may' : puts 5
when 'june' : puts 6
when 'july' : puts 7
when 'august' : puts 8
when 'september' : puts 9
when 'october' : puts 10
when 'november' : puts 11
when 'december' : puts 12
end
end
end
## posts_controller.rb
class PostsController < ApplicationController
load_and_authorize_resource
include DateMadness
##