query.rb 481 B

12345678910111213141516171819
  1. module Blazer
  2. class Query < ActiveRecord::Base
  3. belongs_to :creator, class_name: Blazer.user_class.to_s if Blazer.user_class
  4. has_many :checks, dependent: :destroy
  5. has_many :dashboard_queries, dependent: :destroy
  6. has_many :audits
  7. validates :name, presence: true
  8. validates :statement, presence: true
  9. def to_param
  10. [id, name.gsub("'", "").parameterize].join("-")
  11. end
  12. def friendly_name
  13. name.gsub(/\[.+\]/, "").strip
  14. end
  15. end
  16. end