I have two action in the same controller:
def list if logged_in? sort = case params['sort'] when "title" then "title" when "a" then "a" when "b" then "b" when "c" then "c" when "title_reverse" then "title DESC" when "a_reverse" then "a DESC" when "b_reverse" then "b DESC" when "c_reverse" then "c DESC" end
if params[:query]==nil conditions = ["login LIKE ?", "%#{current_user.login}%"] else conditions = ["login LIKE ? and title LIKE ?", "%#{current_user.login}%","%#{params[:query]}%"] end @total = Suma.count(:conditions => conditions) @sumas = Suma.paginate :all, :order => sort, :conditions => conditions, :per_page => @total+1, :page => 1 if request.xml_http_request? render :partial => "items_list", :layout => false end else redirect_back_or_default('/') end end
And I have other action :
def xls