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?
matthew collins wrote:> 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? > > _______________________________________________ > Rails mailing list > 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
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.> From: matthew collins <matthewcollins@cfl.rr.com> > Reply-To: <rails@lists.rubyonrails.org> > Date: Sun, 05 Feb 2006 16:53:48 -0500 > To: <rails@lists.rubyonrails.org> > Subject: [Rails] accessing the values in a view > > 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? > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails