This should do the trick and be quite easy to read/maintain.
Controller methods: (Add redirects or renders as appropriate)
# Make sure this remains in before_filter for the increment and decrement methods too
def set_month_view
session[:month_view] ||= DateTime.new(Time.now.year, Time.now.month, 1, 0, 0, 0, "+00:00")
end
def increment_month_view
session[:month_view] = session[:month_view] + 1.month
end
def decrement_month_view
session[:month_view] = session[:month_view] - 1.month
end
View links:
You are viewing month: <%= session[:month_view] %>
<%= link_to 'backwards', decrement_month_view_controller_path %>
<%= link_to 'forwards', increment_month_view_controller_path %>