Sha256: 65de331ead0a618ba8966d59284016142f6b8a648e838801ef2cc8a91e657d95

Contents?: true

Size: 1.36 KB

Versions: 41

Compression:

Stored size: 1.36 KB

Contents

# -*- encoding : utf-8 -*-
class Jinda::Doc
  include Mongoid::Document
  include Mongoid::Timestamps
  include Mongoid::Attributes::Dynamic
  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 :description, :type => String
  field :category, :type => String
  field :ma_display, :type => Boolean
  field :ma_secured, :type => Boolean
  field :dscan, :type => String
  field :keywords, :type => String

  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

41 entries across 38 versions & 3 rubygems

Version Path
jinda-0.8.0 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.8.0 test/dummy/app/models/jinda/doc.rb
jinda-0.7.7.4 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.7.7.4 test/dummy/app/models/jinda/doc.rb
jinda-0.7.7.3 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.7.7.3 test/dummy/app/models/jinda/doc.rb
jinda-0.7.7.2 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.7.7.1 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda_mind-1.0.0 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.7.7 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.7.6 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.7.5.5 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.7.5.4 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.7.5.3 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.7.5.2 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.7.5.0 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.7.3 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.7.2 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.7.1 lib/generators/jinda/templates/app/models/jinda/doc.rb
jinda-0.7.0.4 lib/generators/jinda/templates/app/models/jinda/doc.rb