# Need help with if statement in helper class and view

**URL:** <https://www.ruby-forum.com/t/need-help-with-if-statement-in-helper-class-and-view/88250>\
**Category:** Ruby\
**Created:** [March 9, 2007, 6:06am UTC](https://www.ruby-forum.com/t/need-help-with-if-statement-in-helper-class-and-view/88250 "2007-03-09T06:06:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 9, 2007, 6:06am UTC](https://www.ruby-forum.com/t/need-help-with-if-statement-in-helper-class-and-view/88250/1 "2007-03-09T06:06:03Z")

</div>

I don’t know if this is a ruby only question or a rails question. I  
have a helper class that updates the view based on the info from the  
div tag. This information is passed using the link\_to\_function. But it  
doesn’t work. I don’t know how to access the page elements. Also, is  
the if statement syntax correct for ruby? Thank you in advance for any  
help.

Is it if x1 == ‘x1’ or is it if x1 = ‘x1’?

module VideosHelper  
def hide\_and\_reset(div, div2)  
update\_page do |page|  
if page[div].title == ‘show’  
page[div].hide  
page[div].title = ‘hide’  
else  
page[div].show  
page[div].title = ‘show’  
end  
end  
end

\<%= link\_to\_function image\_tag("graphics/ select04.gif", :alt=\>'Programming', :size=\>'100x20', :border=\>0), hide\_and\_reset(:select02\_div, :select01\_div) %\>

#### test

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 9, 2007, 6:59am UTC](https://www.ruby-forum.com/t/need-help-with-if-statement-in-helper-class-and-view/88250/2 "2007-03-09T06:59:06Z")

</div>

The equality operator in Ruby is ==

As for the question regarding accessing and updating page elements  
that is better suited for the Rails talk list. However, the key to how  
to work with elements might be at  
[http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods.html](http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods.html)

V/r  
Anthony E.
