rails: render a collection of models using an specific html view

ruby, ruby-on-rails, ruby-on-rails-3

Solution

You can use the `collection` option:

<%= render :collection => User.all, :partial => "users/user2ndview", 
           :as => :user %>

The view must be placed in views/users/_user2ndview

See the Rails guides on rendering collections for more details.

Problem

I have the following simple problem with rails. Let say I have a model User. In a view, if I do: ``` <%= render User.all %> ``` The file view in views/user/_user.html.erb will be called and printed for each of the users. How can I change this to use an specific view? I need something like: ``` <%= render :data=>User.all :template=>"user/_user_2ndview.html"%> ``` Any help? Thanks in advance

Original source