# Variable Losing it's Value

**URL:** <https://www.ruby-forum.com/t/variable-losing-its-value/97966>\
**Category:** Rails\
**Created:** [July 11, 2006, 6:29pm UTC](https://www.ruby-forum.com/t/variable-losing-its-value/97966 "2006-07-11T18:29:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![joel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@joel](https://www.ruby-forum.com/u/joel)\
**Post date:** [July 11, 2006, 6:29pm UTC](https://www.ruby-forum.com/t/variable-losing-its-value/97966/1 "2006-07-11T18:29:35Z")

</div>

I fired up my rails app after a few weeks, only to find it was broken,  
in that the variable seems to be losing it’s value somewhere between the  
controller and the view. I’ve broken it down to the absolute simplest  
test, and here is what I get:

THE CONTROLLER (controllers/visits\_controller.rb)  
class VisitsController \< ApplicationController  
def list  
@test = “test”  
end  
end

THE VIEW (views/visits/list.rhtml)  
Testing: \<%= @test %\>

THE RESULT ([http://logapp/visits/list.rhtml](http://logapp/visits/list.rhtml))  
Testing:

EXPECTED REUSULT  
Testing: test

A ‘@test.inspect’ returns ‘nil’. Any ideas? Thanks.

---

<div class="post-metadata">

**Author:** ![joel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@joel](https://www.ruby-forum.com/u/joel)\
**Post date:** [July 11, 2006, 10:43pm UTC](https://www.ruby-forum.com/t/variable-losing-its-value/97966/2 "2006-07-11T22:43:47Z")

</div>

Not sure if you’ve just made a typo… but lose the “.rhtml” off the  
url.

Cheers  
-h

---

<div class="post-metadata">

**Author:** ![joel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@joel](https://www.ruby-forum.com/u/joel)\
**Post date:** [July 11, 2006, 10:50pm UTC](https://www.ruby-forum.com/t/variable-losing-its-value/97966/3 "2006-07-11T22:50:27Z")

</div>

Hi –

On Tue, 11 Jul 2006, Joel wrote:

> end
> 
> A ‘@test.inspect’ returns ‘nil’. Any ideas? Thanks.

Drop “.rhtml” from the URL.

David

–  
[http://www.rubypowerandlight.com](http://www.rubypowerandlight.com) =\> Ruby/Rails training & consultancy  
[Ruby for Rails](http://www.manning.com/black) =\> RUBY FOR RAILS, the Ruby book for  
Rails developers  
[http://dablog.rubypal.com](http://dablog.rubypal.com) =\> D[avid]A[.]B[lack’s][Web]log  
removed\_email\_address@domain.invalid =\> me

---

<div class="post-metadata">

**Author:** ![joel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@joel](https://www.ruby-forum.com/u/joel)\
**Post date:** [July 12, 2006, 1:18am UTC](https://www.ruby-forum.com/t/variable-losing-its-value/97966/4 "2006-07-12T01:18:51Z")

</div>

removed\_email\_address@domain.invalid wrote:

> Drop “.rhtml” from the URL.

Excellent! Can’t believe I missed that. Duh ;-(

Best regards,  
Bill

---

<div class="post-metadata">

**Author:** ![joel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@joel](https://www.ruby-forum.com/u/joel)\
**Post date:** [July 12, 2006, 2:30pm UTC](https://www.ruby-forum.com/t/variable-losing-its-value/97966/5 "2006-07-12T14:30:06Z")

</div>

Yep, that did the trick. Thanks for the help.

Joel
