Class: RailsVitals::PlaygroundsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/rails_vitals/playgrounds_controller.rb', line 10

def create
  expression = params[:expression].to_s.strip
  clean_expr = clean_expression(expression)
  access_associations = Array(params[:access_associations]).reject(&:blank?)

  result = Playground::Sandbox.run(
    expression,
    access_associations: access_associations
  )

  model_name = Playground::Sandbox.extract_model_name(expression)
  @available_assocs = associations_for_model(model_name)
  @prechecked_assocs = access_associations

  @expression = clean_expr
  @result = result
  @previous = session_previous
  @query_dna = build_dna(result.queries)

  session[:playground_previous] = serialize_result(result, clean_expr, access_associations)

  render :index
end

#indexObject



3
4
5
6
7
8
# File 'app/controllers/rails_vitals/playgrounds_controller.rb', line 3

def index
  @default_query = default_query
  @default_model = default_model_name
  @available_assocs = associations_for_model(@default_model)
  @prechecked_assocs = prechecked_associations
end