app/controllers/prosperity/graphs_controller.rb in prosperity-0.0.7 vs app/controllers/prosperity/graphs_controller.rb in prosperity-0.0.8
- old
+ new
@@ -1,10 +1,10 @@
require_dependency "prosperity/application_controller"
module Prosperity
class GraphsController < ApplicationController
- before_action :get_graph, only: [:edit, :update, :show]
+ before_action :get_graph, only: [:edit, :update]
def new
@graph = Graph.new
end
def edit
@@ -17,10 +17,11 @@
end
def show
respond_to do |format|
format.json do
+ get_graph
render json: {
title: @graph.title,
graph_type: @graph.graph_type,
extractors: @graph.graph_lines.map do |line|
{
@@ -35,9 +36,16 @@
end
}
end
format.html {
+ begin
+ get_graph
+ rescue ActiveRecord::RecordNotFound
+ @graph = nil
+ render layout: 'prosperity/embedabble', status: :not_found
+ return
+ end
render layout: 'prosperity/embedabble'
}
end
end