A more Rails way to do it would be:

```ruby
Date.today.advance(years: params[:year], months: params[:month]).beginning_of_month
```