Controller
def list_all_tasks
add_to_sortable_columns('listing', Task, 'task_name')
add_to_sortable_columns('listing', Task, 'finish_time')
add_to_sortable_columns('listing', Goal, 'name')
@tasks = Task.find(:all, :include => :goal, :order => sortable_order('listing', Task, 'task_name'))
end
View
<%= link_to '任務名稱', sort_param('listing', Task, 'task_name') %>
<%= link_to '任務完成時間', sort_param('listing', Task, 'finish_time') %>
<%= link_to '任務所屬目標', sort_param('listing', Goal, 'name') %>
add_to_sortable_columns 是加在需要的controller's action
沒有留言:
張貼留言