Forum: Ruby on Rails passing several instant variables to a rjs file

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
9fa0e9901902a1eb76217f33bd15c4a2?d=identicon&s=25 jochen kaechelin (Guest)
on 2007-05-26 18:50
(Received via mailing list)
I have  controller:

   def liste
    @tags_pages, @tags = paginate(:tags, :order => "tags desc")

and a RJS-file (liste.rjs):

   page[:main].replace_html :partial => "liste", :object => @tags ?????

and a RHTML-file (_liste.rhtml):

  <% for a in @tags %>
  <%= a.tag.downcase %>
  <% end %>

I want to display a page with all tags in the database. Because
there are a hundred of them I want' to use pagination. But to use
the RJS file I need @tags_pages AND @tags in it.

How to manage this?
D7c511ce5025d37b8c6bd9134e0f2bd9?d=identicon&s=25 Thorsten (Guest)
on 2007-05-27 13:24
(Received via mailing list)
Didn't try it yet, but from what the API docs of ActionView and
ActionController say about the render command, you should be able to
just pass a hash:

from API:
You can pass local variables to sub templates by using a hash with the
variable names as keys and the objects as values:

  <%= render "shared/header", { :headline => "Welcome", :person =>
person } %>

so try this:

page[:main].replace_html :partial => "liste", {:tags =>
@tags, :tag_pages => @tag_pages }
This topic is locked and can not be replied to.