comparing two number

I am trying to do this conditional statement

<% if(@company.id == params[:id]) %> Do This <% end %>

The numbers that it is comparing are the same in the example that I am trying but it always equates to false. Why would this be.

One other thing, it is saying that

@company.id is a fixnum and I assume that params[:id] is a string

I am trying to do this conditional statement

<% if(@company.id == params[:id]) %> Do This <% end %>

The numbers that it is comparing are the same in the example that I am trying but it always equates to false. Why would this be.

because params[:id] is a string.

Fred

params[:id] is actually a string. use params[:id].to_i. :slight_smile:

RSL

You're comparing a fixnum (id) with a string (params) here

<% if(@company.id == params[:id].to_i) %>

should work

Thanks everyone, it worked