[newbie] if expression "weirdness"

Ok first i am running linux with lighttpd and apache proxy’ing to the
lighttpd process.
ruby version is
ruby 1.8.4 (2005-12-24) [i686-linux]

def test
@count = Question.count

if(@params[:id]) then
  breakpoint()

  if (params[:id].to_i > @count) then
     redirect_to :action => 'finish'
  end

end
end

this is a stripped down version of the whole method. the probably that i
am having is the if expression is not evaluating to true when the :id
param is > @count. i have changed a bunch of things tried using @params
to no avalibilty.

But the “weirdness” part comes in when i access the breakpoint() and do
the evaluation in the irb console it does evaluate to true. So i have
been pulling my hair trying to figure out why in the regular controller
it isn’t.

Rob S.

On Sun, Feb 12, 2006 at 06:49:03AM +0100, Rob S. wrote:

  if (params[:id].to_i > @count) then
     redirect_to :action => 'finish'
  end

end
end

this is a stripped down version of the whole method. the probably that i
am having is the if expression is not evaluating to true when the :id
param is > @count. i have changed a bunch of things tried using @params
to no avalibilty.
[…]

You have params[:id] instead of @params[:id] in the second if.


- Adam

** Expert Technical Project and Business Management
**** System Performance Analysis and Architecture
****** [ http://www.everylastounce.com ]

[ Adam Fields (weblog) - - entertaining hundreds of millions of eyeball atoms every day ] … Blog
[ Adam Fields Resume ]… Experience
[ Adam Fields | Flickr ] … Photos
[ http://www.aquicki.com/wiki ]…Wiki
[ http://del.icio.us/fields ] … Links

Adam F. wrote:

On Sun, Feb 12, 2006 at 06:49:03AM +0100, Rob S. wrote:
[…]

You have params[:id] instead of @params[:id] in the second if.


Yes that more copy and paste of parts after changing them around to try
and figure out what is going on. but i stated that i have tried using
@params already and that still doesn’t work. I had been looking around
at other rails source’s like rforum and typo and they don’t seem to be
consitent with using @params or params and i have noticed in the
debugger that both work the same.

On Sun, Feb 12, 2006 at 07:04:49AM +0100, Rob S. wrote:

Yes that more copy and paste of parts after changing them around to try
and figure out what is going on. but i stated that i have tried using
@params already and that still doesn’t work. I had been looking around
at other rails source’s like rforum and typo and they don’t seem to be
consitent with using @params or params and i have noticed in the
debugger that both work the same.

Did you try debug(@params) and debug(@count) to see what they’re
actually passing to the view?


- Adam

** Expert Technical Project and Business Management
**** System Performance Analysis and Architecture
****** [ http://www.everylastounce.com ]

[ Adam Fields (weblog) - - entertaining hundreds of millions of eyeball atoms every day ] … Blog
[ Adam Fields Resume ]… Experience
[ Adam Fields | Flickr ] … Photos
[ http://www.aquicki.com/wiki ]…Wiki
[ http://del.icio.us/fields ] … Links

Adam F. wrote:

On Sun, Feb 12, 2006 at 07:04:49AM +0100, Rob S. wrote:

Did you try debug(@params) and debug(@count) to see what they’re
actually passing to the view?

Yes i have and they are passing the correct variables. why i say its
weird is that because when i use the breakpoint() and lanch the
script/breakpointer to launch a irb session with the framework already
running i can manaully type the same exact expression and it evaluates
to true. But in the controller it doesn’t so i am lost as to whats going
on.