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! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
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. -- Michael Wang --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You were right. I had to do the following to get it to work: params[:route_id].to_i Thanks! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---