# \[newbie\] if expression "weirdness"

**URL:** <https://www.ruby-forum.com/t/newbie-if-expression-weirdness/53627>\
**Category:** Rails\
**Created:** [February 12, 2006, 6:49am UTC](https://www.ruby-forum.com/t/newbie-if-expression-weirdness/53627 "2006-02-12T06:49:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rsanheim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/47e85d/32.png) [@rsanheim](https://www.ruby-forum.com/u/rsanheim)\
**Post date:** [February 12, 2006, 6:49am UTC](https://www.ruby-forum.com/t/newbie-if-expression-weirdness/53627/1 "2006-02-12T06:49:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rsanheim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/47e85d/32.png) [@rsanheim](https://www.ruby-forum.com/u/rsanheim)\
**Post date:** [February 12, 2006, 6:56am UTC](https://www.ruby-forum.com/t/newbie-if-expression-weirdness/53627/2 "2006-02-12T06:56:18Z")

</div>

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](http://www.everylastounce.com) ]

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

---

<div class="post-metadata">

**Author:** ![rsanheim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/47e85d/32.png) [@rsanheim](https://www.ruby-forum.com/u/rsanheim)\
**Post date:** [February 12, 2006, 7:04am UTC](https://www.ruby-forum.com/t/newbie-if-expression-weirdness/53627/3 "2006-02-12T07:04:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rsanheim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/47e85d/32.png) [@rsanheim](https://www.ruby-forum.com/u/rsanheim)\
**Post date:** [February 12, 2006, 3:26pm UTC](https://www.ruby-forum.com/t/newbie-if-expression-weirdness/53627/4 "2006-02-12T15:26:20Z")

</div>

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](http://www.everylastounce.com) ]

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

---

<div class="post-metadata">

**Author:** ![rsanheim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/47e85d/32.png) [@rsanheim](https://www.ruby-forum.com/u/rsanheim)\
**Post date:** [February 12, 2006, 7:23pm UTC](https://www.ruby-forum.com/t/newbie-if-expression-weirdness/53627/5 "2006-02-12T19:23:50Z")

</div>

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.
