RoR - URL params hash help
Having a little both getting this to work. Wondering if someone can help. Basically I am trying to come up with the following url:
This is going to form the basis for a news archive. However I want to do a few checks first to make sure what I expect is there in the URL. I have the following piece of code in my controller.
The view prints the month and year variables fine when everything is in the url as above. However if one of the the year or month params part of the url is missing then no default month or year variables I set before the check aren't showen in the view.
Can anyone help or recomend of a better way of doing this?
@month = 04 (Would be the current month)
@year = 2009 (Would be the current year)
if defined? params[:date][:month] then
@month = params[:date][:month]
if defined? params[:date][:year] then
@year = params[:date][:year]