Sha256: 67ba197976a13ff7c35da9a09b4d1b0ca11b37162bad6a0f148c5fdb192dc87e

Contents?: true

Size: 736 Bytes

Versions: 9

Compression:

Stored size: 736 Bytes

Contents

if Object.const_defined?("Mongoid")
  class Post
    include Mongoid::Document
    include Mongoid::Timestamps
    include Mongoid::History::Trackable
    
    # Columns
    field :title, :type => String
    field :content, :type => String
    field :is_visible, :type => Boolean

    belongs_to :structure, :index => true
    
    delegate :title, :parent_id, :slug, :to => :structure, :prefix => true

    track_history :on => [:title, :content]
    
    def self.sunrise_search(params)
      query = scoped
      
      query = query.where(:title => params[:title]) unless params[:title].blank?
      query = query.where(:structure_id => params[:structure_id]) unless params[:structure_id].blank?
      
      query
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sunrise-cms-0.5.3 spec/dummy/app/models/mongoid/post.rb
sunrise-cms-0.5.2 spec/dummy/app/models/mongoid/post.rb
sunrise-cms-0.5.1 spec/dummy/app/models/mongoid/post.rb
sunrise-cms-0.5.0 spec/dummy/app/models/mongoid/post.rb
sunrise-cms-0.5.0.rc5 spec/dummy/app/models/mongoid/post.rb
sunrise-cms-0.5.0.rc4 spec/dummy/app/models/mongoid/post.rb
sunrise-cms-0.5.0.rc3 spec/dummy/app/models/mongoid/post.rb
sunrise-cms-0.5.0.rc2 spec/dummy/app/models/mongoid/post.rb
sunrise-cms-0.5.0.rc1 spec/dummy/app/models/mongoid/post.rb