Sha256: b54ccc05b51fb996c5ca687d7038037f7bbbe7595d850374af84050a71fee8f1

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

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 gma_user_id=?)",
      "output", "%#{q}%", false, session[:user_id] ],
      :order=>'gma_xmain_id DESC', :select=>'DISTINCT gma_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=>'gma_xmain_id DESC', :select=>'DISTINCT gma_xmain_id'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mindapp-0.0.1 lib/generators/mindapp/templates/app/models/mindapp/doc.rb