Class: TrendsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/trends_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#api_request?, #welcome

Methods included from Foreman::ThreadSession::Cleaner

#clear_thread, included

Instance Method Details

#countObject


46
47
48
49
# File 'app/controllers/trends_controller.rb', line 46

def count
  TrendImporter.update!
  redirect_to trends_url
end

#createObject


15
16
17
18
19
20
21
22
23
# File 'app/controllers/trends_controller.rb', line 15

def create
  params[:trend] ||= { }
  @trend         = params[:trend][:trendable_type] == 'FactName' ? FactTrend.new(params[:trend]) : ForemanTrend.new(params[:trend])
  if @trend.save
    process_success
  else
    process_error
  end
end

#destroyObject


38
39
40
41
42
43
44
# File 'app/controllers/trends_controller.rb', line 38

def destroy
  if @trend.destroy
    process_success
  else
    process_error
  end
end

#editObject


34
35
# File 'app/controllers/trends_controller.rb', line 34

def edit
end

#indexObject


4
5
6
# File 'app/controllers/trends_controller.rb', line 4

def index
  @trends = Trend.types.includes(:trendable).sort_by {|e| e.type_name.downcase }.paginate(:page => params[:page])
end

#newObject


8
9
10
# File 'app/controllers/trends_controller.rb', line 8

def new
  @trend = Trend.new
end

#showObject


12
13
# File 'app/controllers/trends_controller.rb', line 12

def show
end

#updateObject


25
26
27
28
29
30
31
32
# File 'app/controllers/trends_controller.rb', line 25

def update
@trends = Trend.update(params[:trend].keys, params[:trend].values).reject { |p| p.errors.empty? }
if @trends.empty?
    process_success
  else
    process_error
  end
end