I have a ransack search form which is working wonderfully, I would like to add an export for the user to send the contents of the result set to an XLS file.
I have implemented the to_xls sucessfully as well, however it is giving me back the fullest possible scope of the object I am searching, and not the filtered results that are shown in the view.
def index
@search = Expense.search(params[:q])
@expense_list = @search.result.sort_by(&:expense_date)
respond_to do |format|
format.html
format.xml { render :xml => @expense_list }
format.xls { send_data @expense_list.to_xls, :filename => '123.xls'}
end
end
Does it have something to do with how ransack uses the GET method? Any help would be great.
Thanks!