Sha256: 1d9f56c83232ec8a02cca774be3c2d0d2423d46687091f281b6305a629ab7950

Contents?: true

Size: 1.18 KB

Versions: 7

Compression:

Stored size: 1.18 KB

Contents

# -*- encoding : utf-8 -*-
class Mindapp::Doc
  include Mongoid::Document
  include Mongoid::Timestamps
  field :name, :type => String
  field :filename, :type => String
  field :content_type, :type => String
  field :data_text, :type => String
  field :url, :type => String
  field :basename, :type => String
  field :cloudinary, :type => Boolean
  belongs_to :xmain, :class_name => "Mindapp::Xmain"
  belongs_to :runseq, :class_name => "Mindapp::Runseq"
  belongs_to :user
  belongs_to :service, :class_name => "Mindapp::Service"
  field :ip, :type => String
  field :display, :type => Boolean
  field :secured, :type => Boolean

  def self.search(q, page, per_page=PER_PAGE)
    paginate :per_page=>per_page, :page => page, :conditions =>
      ["content_type=? AND data_text LIKE ? AND (secured=? OR ma_user_id=?)",
      "output", "%#{q}%", false, session[:user_id] ],
      :order=>'ma_xmain_id DESC', :select=>'DISTINCT ma_xmain_id'
  end
  def self.search_secured(q, page, per_page=PER_PAGE)
    paginate :per_page=>per_page, :page => page, :conditions =>
      ["content_type=? AND data_text LIKE ?", "output", "%#{q}%" ],
      :order=>'ma_xmain_id DESC', :select=>'DISTINCT ma_xmain_id'
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mindapp-0.0.8 lib/generators/mindapp/templates/app/models/mindapp/doc.rb
mindapp-0.0.7 lib/generators/mindapp/templates/app/models/mindapp/doc.rb
mindapp-0.0.6 lib/generators/mindapp/templates/app/models/mindapp/doc.rb
mindapp-0.0.5 lib/generators/mindapp/templates/app/models/mindapp/doc.rb
mindapp-0.0.4 lib/generators/mindapp/templates/app/models/mindapp/doc.rb
mindapp-0.0.3 lib/generators/mindapp/templates/app/models/mindapp/doc.rb
mindapp-0.0.2 lib/generators/mindapp/templates/app/models/mindapp/doc.rb