ruby - Purpose of @ in ERB templates -



ruby - Purpose of @ in ERB templates -

this question has reply here:

@ variables in ruby on rails 6 answers

i've seen code in erb templates:

<%= @some_variable %>

and seen code this:

<%= node[:some_attribute][:some_other_attribute] %>

and plain old

<%= some_variable %>

is there difference? should concerned?

generally @ used if instance variable. mutual utilize of these in controller when want pass variable view render it.

for illustration might have

class foocontroller < applicationcontroller def show @foo = foo.find_by_id(params[:id]) end end

and in corresponding show page access foo calling:

<%= @foo.bar %>

this useful when rendering many show pages many different foos.

ruby syntax erb

Comments

Popular posts from this blog

javascript - THREE.js reposition vertices for RingGeometry -

javascript - I need to update the text of a paragraph by inline edit -

assembly - What is the addressing mode for ld, add, and rjmp instructions? -