class User < ActiveRecord::Base
has_and_belongs_to_many :clients, :order => "name ASC"
end
should do the trick
On 12/21/05, Brutyn Nick
<brutyn_nick-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org>
wrote:>
> hey,
> µ
> i have these records in my database, in a many-to-many relationship
>
> clients_users
> 1;66
> 2;66
> 3;66
> 5;66
> 6;66
> 7;66
> 8;66
> 14;66
> 15;66
> 16;66
> 17;66
> 18;66
> 19;66
> 20;66
> 21;66
> 22;66
>
> clients
> 1;VME Complex Foster
> 2;VME Res. Canada
> 3;Twodecode
> 5;Index
> 6;Verleye bvba
> 7;Venus bvba
> 8;All Building Services nv
> 14;Vitro-Service sa
> 15;Vitro-Clean
> 16;Vecom nv
> 17;Ultra lean bvba
> 18;Solar Cleaning Services nv
> 19;Service Net nv
> 20;Schoonmaakbedrijf VIP-Clean
> 21;Romarco nv
> 22;Pele
>
> i want to sort those clients.
>
> in my controller i have this
>
> @clients_access = @user.clients
>
> in my rhtml
> <% for client in @clients_access %>
> <option value="<%= client.id %>"><%=
client.name %></option>
> <% end %>
>
> with output this
> <option value="1">VME Complex Foster</option>
> <option value="2">VME Res. Canada</option>
> <option value="3">Twodecode</option>
> <option value="5">Index</option>
> <option value="6">Verleye bvba</option>
> <ption value="7">Venus bvba</option>
> ...........
>
> can anyone help me sort them?
>
> Thanks
> Nick
>
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails