# Wondering and worring about veriable scope

**URL:** <https://www.ruby-forum.com/t/wondering-and-worring-about-veriable-scope/110530>\
**Category:** Rails\
**Created:** [July 27, 2007, 7:41am UTC](https://www.ruby-forum.com/t/wondering-and-worring-about-veriable-scope/110530 "2007-07-27T07:41:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![selva](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/13edae/32.png) [@selva](https://www.ruby-forum.com/u/selva)\
**Post date:** [July 27, 2007, 7:41am UTC](https://www.ruby-forum.com/t/wondering-and-worring-about-veriable-scope/110530/1 "2007-07-27T07:41:10Z")

</div>

Hi,

Still yesterday my aplication was working fine. Today i got problem  
in veriable scope…

Acually there is a ‘if’ condintion  
Mistakenly i created one object inside and i was accessing that object  
outside of that if condition.

For example,

```
if user
 role=Role.new
 role.name='john'
 role.save
end

```

After that i try to access that role

```
 role_id=role.id

```

Is it correct?

My friend also got same kind of problem recently…

Or am i doing wrong?.But today only i got problem…Thats why I got  
confusion…Or any silly things i am doing??? Or any automatic update  
in my server? (So ruby version may be changed…)
