Class: Blazer::ChecksController
- Inherits:
-
BaseController
- Object
- ApplicationController
- BaseController
- Blazer::ChecksController
- Defined in:
- app/controllers/blazer/checks_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/blazer/checks_controller.rb', line 16 def create @check = Blazer::Check.new(check_params) # use creator_id instead of creator # since we setup association without checking if column exists @check.creator = blazer_user if @check.respond_to?(:creator_id=) && blazer_user if @check.save redirect_to query_path(@check.query) else render_errors @check end end |
#destroy ⇒ Object
37 38 39 40 |
# File 'app/controllers/blazer/checks_controller.rb', line 37 def destroy @check.destroy redirect_to checks_path end |
#index ⇒ Object
7 8 9 10 11 |
# File 'app/controllers/blazer/checks_controller.rb', line 7 def index state_order = [nil, "disabled", "error", "timed out", "failing", "passing"] @checks = Blazer::Check.joins(:query).includes(:query).order("blazer_queries.name, blazer_checks.id").to_a.sort_by { |q| state_order.index(q.state) || 99 } @checks.select! { |c| "#{c.query.name} #{c.emails}".downcase.include?(params[:q]) } if params[:q] end |
#new ⇒ Object
13 14 |
# File 'app/controllers/blazer/checks_controller.rb', line 13 def new end |
#run ⇒ Object
42 43 44 45 |
# File 'app/controllers/blazer/checks_controller.rb', line 42 def run @query = @check.query redirect_to query_path(@query) end |
#update ⇒ Object
29 30 31 32 33 34 35 |
# File 'app/controllers/blazer/checks_controller.rb', line 29 def update if @check.update(check_params) redirect_to query_path(@check.query) else render_errors @check end end |