Sha256: c9dfa2c0750659691bd23e6e4d81273ba7ecf0755b54222229d465119579d8b3

Contents?: true

Size: 1.21 KB

Versions: 6

Compression:

Stored size: 1.21 KB

Contents

# -*- encoding : utf-8 -*-
class Jinda::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 => "Jinda::Xmain"
  belongs_to :runseq, :class_name => "Jinda::Runseq"
  belongs_to :user, :class_name => "Jinda::User"
  belongs_to :service, :class_name => "Jinda::Service"
  field :ip, :type => String
  field :ma_display, :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

6 entries across 6 versions & 1 rubygems

Version Path
jinda-0.3.9 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.3.8 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.3.7 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.3.6 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.3.5 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.3.4 lib/generators/jinda/templates/app/models/jinda/doc.rb