Forum: Ruby on Rails Codes work in console, irb, but not on website

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
28c7ef5ffd77ddcaf495aa389103b764?d=identicon&s=25 Jason (Guest)
on 2007-04-05 23:00
I have the following code in my controller:

   rid = params[:route_id]
   salesorders = SalesOrder.find(:all)
   @sales_orders = []

   for so in salesorders
      if not so.latest_history.nil?
        if so.latest_history.route_id == rid
          @sales_orders << so

If I use script/console, using the integer 2 instead of the
params[:route_id], it returns 19 results into @sales_orders.  When I run
it on my site, I get 0 results.  What's the difference?  I ran
debug(params) and it's showing params[:route_id] is begin set to 2.

Any ideas?

Dfd6f9989147955682701da8227df8b4?d=identicon&s=25 Michael Wang (Guest)
on 2007-04-06 07:07
(Received via mailing list)
Jason wrote:
>           @sales_orders << so
> Any ideas?
> Thanks!

Probably a data type mismatch. E.g. one is a string and the other is an

Michael Wang
28c7ef5ffd77ddcaf495aa389103b764?d=identicon&s=25 Jason (Guest)
on 2007-04-10 16:10
You were right.

I had to do the following to get it to work:


This topic is locked and can not be replied to.