Sha256: 08045c7d32c3d50f46316e95930a1386edb942ce4acbcf0fcf31e409ef28f181

Contents?: true

Size: 1.18 KB

Versions: 26

Compression:

Stored size: 1.18 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
  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

26 entries across 26 versions & 1 rubygems

Version Path
jinda-0.5.2 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.5.1 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.5.0 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.3.3 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.3.2 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.3.1 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.3.0 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.2.9 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.2.8 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.2.7 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.2.6 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.2.5 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.2.4 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.2.3 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.2.2 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.2.1 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.2.0 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.1.9 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.1.8 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.1.7 lib/generators/jinda/templates/app/models/jinda/doc.rb