given a simple table like this:
orders.id
orders.client_id
orders.supplier_id
orders.date_ordered
I create and index view that has in it something like this:
<td><%= @orders.id %></td>
<td><%= @orders.client_name %></td>
<td><%= @orders.supplier_name %></td>
<td><%= @orders.date_ordered %></td>
Ultimately, I'm wanting to provide an 'index' page, that can be
resorted on a column of the users choice (i.e.id, client_name,
suplier_name, date_ordered)
So thats obviously easy for date_ordered, and id
i.e.
Order.find(:all, :order=>"date_ordered") for example
BUT to sort by the the client name or supplier name, data which are
obviously in a joined table - it gets curlier. Coming from an sql
background, i'd assume it should be very very simple, but activerecord
seems to obscure something simple and make it a guessing game of
syntax - ok - probably not a fair comment... can someone set me
straight on this and show me how ?
given a simple table like this:
orders.id
orders.client_id
orders.supplier_id
orders.date_ordered
I create and index view that has in it something like this:
<td><%= @orders.id %></td>
<td><%= @orders.client_name %></td>
<td><%= @orders.supplier_name %></td>
<td><%= @orders.date_ordered %></td>
Ultimately, I'm wanting to provide an 'index' page, that can
be resorted on a column of the users choice (i.e.id,
client_name, suplier_name, date_ordered)
So thats obviously easy for date_ordered, and id i.e.
Order.find(:all, :order=>"date_ordered") for example
BUT to sort by the the client name or supplier name, data
which are obviously in a joined table - it gets curlier.
Coming from an sql background, i'd assume it should be very
very simple, but activerecord seems to obscure something
simple and make it a guessing game of syntax - ok - probably
not a fair comment... can someone set me straight on this and
show me how ?