Sha256: 209fd81b421fc6a23fcfe839c06319df8c3262629409da622bce31524cb4604c

Contents?: true

Size: 509 Bytes

Versions: 73

Compression:

Stored size: 509 Bytes

Contents

module Tenon
  class Gallery < ActiveRecord::Base
    include Tenon::Reorderable
    has_many :photos, inverse_of: :gallery
    accepts_nested_attributes_for :photos, allow_destroy: true, reject_if: ->(p) { p[:file_id].blank? }
    validates_presence_of :title
    validates_uniqueness_of :title
    default_scope { order('tenon_galleries.list_order') }
    has_history includes: [:photos]

    def self.find_with_photos(id)
      includes(:photos).order('tenon_photos.list_order').find(id)
    end
  end
end

Version data entries

73 entries across 73 versions & 1 rubygems

Version Path
tenon-1.0.74 app/models/tenon/gallery.rb
tenon-1.0.73 app/models/tenon/gallery.rb
tenon-1.0.72 app/models/tenon/gallery.rb
tenon-1.0.71 app/models/tenon/gallery.rb
tenon-1.0.70 app/models/tenon/gallery.rb
tenon-1.0.69 app/models/tenon/gallery.rb
tenon-1.0.68 app/models/tenon/gallery.rb
tenon-1.0.67 app/models/tenon/gallery.rb
tenon-1.0.66 app/models/tenon/gallery.rb
tenon-1.0.65 app/models/tenon/gallery.rb
tenon-1.0.64 app/models/tenon/gallery.rb
tenon-1.0.63 app/models/tenon/gallery.rb
tenon-1.0.62 app/models/tenon/gallery.rb
tenon-1.0.61 app/models/tenon/gallery.rb
tenon-1.0.60 app/models/tenon/gallery.rb
tenon-1.0.59 app/models/tenon/gallery.rb
tenon-1.0.57 app/models/tenon/gallery.rb
tenon-1.0.56 app/models/tenon/gallery.rb
tenon-1.0.55 app/models/tenon/gallery.rb
tenon-1.0.54 app/models/tenon/gallery.rb