RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: Nico44
For using this with associations I found the following worked for me (I am displaying a list of transactions, the association is a category). In my Transactions controller:
def index if params[:sort] == "category" @transactions = sort_by_category else @transactions = sort end end private def sort current_user.transactions.order(sort_column + " " + sort_direction).page(params[:page]) end def sort_by_category current_user.transactions.paginate( :page => params[:page], :include => :category, :order => "categories.name #{sort_direction}") end def sort_column Transaction.column_names.include?(params[:sort]) ? params[:sort] : "date" end def sort_direction %w[asc desc].include?(params[:direction]) ? params[:direction] : "desc" end
I'm paging the results with will_paginate but if not paging something along the lines of the following would work I believe:
current_user.transactions.find(:all, :include => :category, :order => "categories.name #{sort_direction}")
Thanks very much, that seems to have done it!
Anyone else getting javascript errors with the Sass variation, i.e.
"$("a[rel=popover]").popover is not a function [Break On This Error]
$("a[rel=popover]").popover();"
Looks like for some reason the bootstrap js files aren't getting served up.
For using this with associations I found the following worked for me (I am displaying a list of transactions, the association is a category). In my Transactions controller:
I'm paging the results with will_paginate but if not paging something along the lines of the following would work I believe:
Thanks very much, that seems to have done it!
Anyone else getting javascript errors with the Sass variation, i.e.
"$("a[rel=popover]").popover is not a function
[Break On This Error]
$("a[rel=popover]").popover();"
Looks like for some reason the bootstrap js files aren't getting served up.