Sha256: daf12be2731e8a59b5f9fe3900be33777da36b301d87f8511a560663cec0b479

Contents?: true

Size: 546 Bytes

Versions: 5

Compression:

Stored size: 546 Bytes

Contents

module Prosperity
  class Graph < ActiveRecord::Base
    has_many :graph_lines, class_name: 'Prosperity::GraphLine'
    validates_presence_of :title, :period
    accepts_nested_attributes_for :graph_lines, reject_if: :not_filled?

    ATTR_ACCESSIBLE = [:title, :period, :graph_lines].freeze

    attr_accessible *ATTR_ACCESSIBLE unless defined?(ActionController::StrongParameters)

    private
    def not_filled?(line)
      if line[:id]
        false
      else
        line[:option].blank? || line[:metric].blank?
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
prosperity-0.0.6 app/models/prosperity/graph.rb
prosperity-0.0.5 app/models/prosperity/graph.rb
prosperity-0.0.4 app/models/prosperity/graph.rb
prosperity-0.0.3 app/models/prosperity/graph.rb
prosperity-0.0.2 app/models/prosperity/graph.rb