Re: using params in a comparison

Alex Wayne
Wed, 28 May 2008 01:56:37 -0000

Dave Lynam wrote:
> Other is a column in the database.  So photo.other is the value in
> this column and I only want to display the photos where the
> params[:id] matches this photo.other value.
>
> On May 27, 6:29 pm, "Ryan Bigg (Radar)"
<radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

  123 == "123" #=> false

The params hash contains strings.  A database column stored as an
integer, will return an integer.  And an integer will not equate to a
string.

  photo.other == params[:id].to_i

or

  photo.other.to_s == params[:id]
--
Posted via http://www.ruby-forum.com/.