Class: SearchesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/searches_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



12
13
14
15
16
17
18
# File 'app/controllers/searches_controller.rb', line 12

def create
  authorize! :create, Search
  @search = Search.new(params[:search])
  @search.organization_id = current_user.current_organization.id
  @search.save!
  redirect_to @search
end

#newObject



6
7
8
9
10
# File 'app/controllers/searches_controller.rb', line 6

def new
  authorize! :view, Search
  @search = Search.new(params[:search])
  prepare_search_and_people
end

#showObject



20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/searches_controller.rb', line 20

def show
  @search = Search.find(params[:id])
  authorize! :view, @search
  @segment = Segment.new
  session[:return_to] ||= request.referer # Record the current page, in case creating a list segment fails.
  prepare_search_and_people
  respond_to do |format|
   format.html
   format.csv { render :csv => @search.people, :filename => "#{@search.id}-#{DateTime.now.strftime("%m-%d-%y")}" }
 end
end

#tagObject



32
33
34
35
36
37
38
# File 'app/controllers/searches_controller.rb', line 32

def tag
  @search = Search.find(params[:id])
  authorize! :tag, Segment
  @search.tag(params[:name])
  flash[:notice] = "We're tagging all the people and we'll be done shortly.  Refresh this page in a minute or two."
  redirect_to @search
end