the scope of the variable.
when you create an @var, if will create a global variable, whereas a var
is a local variable => this means that if you create an action in your
controller (lets say:
def foo1
...
blahblah
@var = "something"
...
end
or alternitively,
def foo2
...
blahblah
var = "something"
end
in the view of foo1.rhtml you will be able to see the "something"
string
by putting
<%= @var %>, whereas in the view of foo2.rhtml you would not be able to
use
<%= var %> - - if would give you an error like "undefined local
variable/method"
((same works for the view itself, say:
======view.rhtml =========
<% for @var in @variables %>
...
<% end %>
<%= @var %> # the variable you want , will work, cause the scope of @
is a global one, not a ''local'' one. . .
whereas:
========view.rhtml ========
<% for var in @variables %>
# here you could use it - - this is the scope of the variable, and it
''dies'' at the end statement.
<% end %>
# but not here!
=====================
hope this helps somewhat. either way, reading some stuff off of
wiki.rubyonrails.com is a great resource.
later,
s
--
Posted via http://www.ruby-forum.com/.