Class: Sage::ChecksController
- Inherits:
-
BaseController
- Object
- Blazer::BaseController
- BaseController
- Sage::ChecksController
- Defined in:
- app/controllers/sage/checks_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/sage/checks_controller.rb', line 24 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
45 46 47 48 |
# File 'app/controllers/sage/checks_controller.rb', line 45 def destroy @check.destroy redirect_to checks_path end |
#index ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/sage/checks_controller.rb', line 5 def index @q = Blazer::Check.ransack(params[:q]) @checks = @q.result.joins(:query).includes(:query) # Apply basic ordering first @checks = @checks.order("blazer_queries.name, blazer_checks.id") # Apply pagination with Pagy @pagy, @checks = pagy(@checks) # Apply state-based sorting on the paginated results state_order = [ nil, "disabled", "error", "timed out", "failing", "passing" ] @checks = @checks.sort_by { |q| state_order.index(q.state) || 99 } end |
#new ⇒ Object
20 21 22 |
# File 'app/controllers/sage/checks_controller.rb', line 20 def new @check = Blazer::Check.new(query_id: params[:query_id]) end |
#run ⇒ Object
50 51 52 53 |
# File 'app/controllers/sage/checks_controller.rb', line 50 def run @query = @check.query redirect_to query_path(@query) end |
#update ⇒ Object
37 38 39 40 41 42 43 |
# File 'app/controllers/sage/checks_controller.rb', line 37 def update if @check.update(check_params) redirect_to query_path(@check.query) else render_errors @check end end |