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.53 app/models/tenon/gallery.rb
tenon-1.0.52 app/models/tenon/gallery.rb
tenon-1.0.51 app/models/tenon/gallery.rb
tenon-1.0.50 app/models/tenon/gallery.rb
tenon-1.0.49 app/models/tenon/gallery.rb
tenon-1.0.48 app/models/tenon/gallery.rb
tenon-1.0.47 app/models/tenon/gallery.rb
tenon-1.0.46 app/models/tenon/gallery.rb
tenon-1.0.45 app/models/tenon/gallery.rb
tenon-1.0.44 app/models/tenon/gallery.rb
tenon-1.0.43 app/models/tenon/gallery.rb
tenon-1.0.42 app/models/tenon/gallery.rb
tenon-1.0.41 app/models/tenon/gallery.rb
tenon-1.0.40 app/models/tenon/gallery.rb
tenon-1.0.39 app/models/tenon/gallery.rb
tenon-1.0.38 app/models/tenon/gallery.rb
tenon-1.0.37 app/models/tenon/gallery.rb
tenon-1.0.36 app/models/tenon/gallery.rb
tenon-1.0.35 app/models/tenon/gallery.rb
tenon-1.0.33 app/models/tenon/gallery.rb