I am using this helper to sort my table colums, no problem sorting on
string but how can I sort a date colum ( in my DB, )
user_helper.rb ----------------------
def sort_link_helper(text, param)
key = param
key += "_reverse" if @params[:sort] == param
options = {
:url => {:action => ''list'', :params =>
@params.merge({:sort =>
key, :page => nil})},
:update => ''table'',
:before => "Element.show(''spinner'')",
:success => "Element.hide(''spinner'')"
}
html_options = {
:title => "Sort by this field",
:href => url_for(:action => ''list'', :params =>
@params.merge({:sort
=> key, :page => nil}))
}
link_to_remote(text, options, html_options)
end
_user_list.rhtml ----------------------- (partial in my list.rhtml)
<tr class="tbl_header">
<td align="center" <%= sort_td_class_helper
"startdate"%>><%=
sort_link_helper "Start", "startdate"></td>
.... table item line -----------
<td width="30%" align="center"><%=
h(booking.startdate.loc("%a %d %b"))
%></td>
I am using paginate in my controller with the sort parameter
user_controller.rb ----------
def list
@bookings = paginate(:bookings, :order => sort,......
--
Posted via http://www.ruby-forum.com/.