Accessing the values in a view


#1

trying to build an archive page

in the controller layout file, i render_component(:action => “archive”),
and that works fine. i turned render(:layout => false) within the
“archive” function.

trouble is, and here’s my confusion. as a test, i simply write

def archive

render(:layout => false)
@archives = 'test'

end

and in the archive.rhtml

<%= @archives %>

but i get nothing? shouldn’t i be able to access @archives?


#2

matthew collins wrote:

@archives = ‘test’
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails

Your archive method should be something like:

def archive
@archives = ‘test’
render(:layout => false)
end

Call render on the last line, because it prepare view to be viewed!


Husein C.,
Software Architect


#3

Try flipping those two statements… If you render before you set the
@archives variable, I wouldn’t imagine it would be available in the
view.