Class: Prosperity::GraphsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Prosperity::GraphsController
- Defined in:
- app/controllers/prosperity/graphs_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/prosperity/graphs_controller.rb', line 43 def create @graph = Graph.new [:title, :period].each do |attr| @graph.send("#{attr}=", graph_params[attr]) end if @graph.save redirect_to edit_graph_path(@graph) else set_error(@graph) render action: :new end end |
#edit ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'app/controllers/prosperity/graphs_controller.rb', line 10 def edit @metrics = MetricFinder.all.map(&:new) = @metrics.inject({}) do |h, metric| h[metric.id] = metric..keys h end @graph.graph_lines.build end |
#new ⇒ Object
6 7 8 |
# File 'app/controllers/prosperity/graphs_controller.rb', line 6 def new @graph = Graph.new end |
#show ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/prosperity/graphs_controller.rb', line 19 def show render json: { title: @graph.title, extractors: @graph.graph_lines.map do |line| { key: line.extractor, url: data_metric_path(id: line.metric, extractor: line.extractor, option: line.option, period: @graph.period, start_time: start_time, end_time: end_time), } end } end |
#update ⇒ Object
36 37 38 39 40 41 |
# File 'app/controllers/prosperity/graphs_controller.rb', line 36 def update unless @graph.update_attributes(graph_params) set_error(@graph) end redirect_to action: :edit end |