Codes work in console, irb, but not on website

Jason wrote:

I have the following code in my controller:

if request.post?
   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
        end
      end
   end
end

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?

Thanks!

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