Sha256: cb671cd01424e9e93ec9a4253f5e8b13017d8914bfc7e9d26562d3ea62a9ce36
Contents?: true
Size: 687 Bytes
Versions: 1
Compression:
Stored size: 687 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?, allow_destroy: true ATTR_ACCESSIBLE = [:title, :period, :graph_lines, :graph_type].freeze attr_accessible *ATTR_ACCESSIBLE unless defined?(ActionController::StrongParameters) VALID_GRAPH_TYPES = %w(line area ratio) validates :graph_type, inclusion: {in: VALID_GRAPH_TYPES} private def not_filled?(line) if line[:id] false else line[:option].blank? || line[:metric].blank? end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
prosperity-0.0.11 | app/models/prosperity/graph.rb |