Tim Shaffer wrote in post #994920:
> The easiest way is probably just "if request.post?"
>
> Be careful though - it could be a post request without the parameters
> you
> are looking for. Might also be helpful to check if the params hash
> contains
> the keys you plan on using.
>
> Another option is to just try it, then ask for forgiveness:
>
> begin
>   Date.new(params[:year].to_i, params[:month].to_i, params[:day].to_i)
> rescue ArgumentError
>   # could not create date from parameters
> end

if request.post?
Date.new(params[:year].to_i, params[:month].to_i, params[:day].to_i)
end

Still throws the same invalid date error.

I also tried:

unless params[:eff_day].to_i.nil?
Date.new(params[:year].to_i, params[:month].to_i, params[:day].to_i)
end

And that at least does not throw an error, but it doesn't seem to work
either.

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to