Attr_accessor not setting or being displayed in the layout

Hi there guys

I’ve been pulling my hair out all night with this one, I thought it
would work?

If in my controller i do the following

class PagesController < ApplicationController
attr_accessor :something
helper_attr :something

def show
something = “display this!”

respond_to do |format|
    format.html
format.xml  { render :xml => @page.to_xml }
end

end
end

Then in my view

<%= something %>

Should “display this!” get displayed? becuase it doesn’t seem to be
setting for me

Thanks in advance :slight_smile:

Camo wrote:

class PagesController < ApplicationController
attr_accessor :something
helper_attr :something

def show
something = “display this!”

respond_to do |format|
    format.html
format.xml  { render :xml => @page.to_xml }
end

end
end

Try self.something = “display this!”. Calling an assignment on just
“something” will assign a variable that is local to that method instead
of the object.


Roderick van Domburg
http://www.nedforce.nl