Forum: Ruby on Rails accessing the values in a view

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.
44c645f2c3a008972d9904102bae09df?d=identicon&s=25 matthew collins (Guest)
on 2006-02-05 22:56
(Received via mailing list)
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?
6b554084eb8bcb53a1c97864d8c4ca0d?d=identicon&s=25 Husein Choroomi (Guest)
on 2006-02-05 23:05
(Received via mailing list)
matthew collins wrote:
>    @archives = 'test'
> Rails@lists.rubyonrails.org
> 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 Choroomi,
Software Architect
A7db9ec803b5895ae5f916a74e2db329?d=identicon&s=25 HH (Guest)
on 2006-02-06 02:42
(Received via mailing list)
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.
This topic is locked and can not be replied to.