Forum: Ruby on Rails Wondering and worring about veriable scope

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Selvaraj S. (Guest)
on 2007-07-27 09:41

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...)
This topic is locked and can not be replied to.