Advertisement
twinfacer

sample controller code

Jun 28th, 2013
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.12 KB | None | 0 0
  1. class SearchesController < ApplicationController
  2.  
  3.   def perform
  4.     @criteria = params[:criteria]
  5.     @simple_header = "Search result for #{@criteria}. "
  6.     respond_to do |format|
  7.       format.js do
  8.         @tab_name = params[:tab]
  9.         if @tab_name == "popular"
  10.           @vectors = Vector.full_search(params[:criteria], :order => :popularity).page(params[:page]).per(Vector::PER_PAGE)
  11.         else
  12.           @vectors = Vector.full_search(params[:criteria], :order => :created_at).page(params[:page]).per(Vector::PER_PAGE)
  13.         end
  14.         @simple_header = "Search result for #{@criteria}. #{@vectors.total_count} vectors found."
  15.         render "shared/vectors_list"
  16.       end
  17.       format.html do
  18.         @vectors = Vector.full_search(params[:criteria], :order => :created_at).page(params[:page]).per(Vector::PER_PAGE)
  19.         @popular_vectors = Vector.full_search(params[:criteria], :order => :popularity).page(params[:page]).per(Vector::PER_PAGE)
  20.         @simple_header = "Search result for #{@criteria}. #{@vectors.total_count} vectors found."
  21.         render "shared/vectors_list"
  22.       end
  23.     end
  24.   end
  25. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement