Контроллер: @users = User.all
Просмотр:
<%= @users %>
Результат [#<User id: 1, email: "a@a.a", location: "London">, #<User id: 2, email: "b@b.b", location: "Paris">]
Как добавить в класс пользователя еще одну пару, не добавляя ее в модель?что-то вроде:
Контроллер: @users.each do |user| <br>
@type = Types.find(:last, :conditions => ["user_id_addressedto = #{user.id}"])
user << @type
end
@users.sort_by(:type)
в конце я хочу видеть результат как:
Вид:
<%= @users %>
Результат: [#<User id: 2, email: "b@b.b", location: "Paris", type: "5">, #<User id: 1, email: "a@a.a", location: "London", type: "2">]