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. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
One other thing, it is saying that @company.id is a fixnum and I assume that params[:id] is a string On Jun 10, 8:51 am, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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.--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 10 Jun 2008, at 12:51, Shawn B wrote:> > 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> > >--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
params[:id] is actually a string. use params[:id].to_i. :) RSL On Tue, Jun 10, 2008 at 7:51 AM, Shawn B <sbanks-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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. > > >--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Jun 10, 1:51 pm, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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.You''re comparing a fixnum (id) with a string (params) here <% if(@company.id == params[:id].to_i) %> should work --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks everyone, it worked On Jun 10, 8:58 am, Thorsten Müller <thors...-1oxKqHKwyltBDgjK7y7TUQ@public.gmane.org> wrote:> On Jun 10, 1:51 pm, Shawn B <sba...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > 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. > > You''re comparing a fixnum (id) with a string (params) here > > <% if(@company.id == params[:id].to_i) %> > > should work--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---