The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

RoR - URL params hash help

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?

Code:

@month = 04 (Would be the current month)
@year = 2009 (Would be the current year)
if defined? params[:date][:month] then
@month = params[:date][:month]
end
if defined? params[:date][:year] then
@year = params[:date][:year]
end