Sha256: dc9546ffb70310dc56aaaa64d1f3cd7c333eb3c0baa7c12b662a22fc84d4e8f5

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 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 :demontrate, :type => Boolean
  field :ma_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 (ma_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_ma_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

4 entries across 4 versions & 1 rubygems

Version Path
mindapp2-0.1.1.3 lib/generators/mindapp/templates/app/models/mindapp/doc.rb
mindapp2-0.1.1.2 lib/generators/mindapp/templates/app/models/mindapp/doc.rb
mindapp2-0.1.1.1 lib/generators/mindapp/templates/app/models/mindapp/doc.rb
mindapp2-0.1.0 lib/generators/mindapp/templates/app/models/mindapp/doc.rb