Class: Newsitem

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document, Mongoid::Timestamps
Defined in:
lib/newsitem.rb

Constant Summary collapse

PER_PAGE =
6

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_params(item) ⇒ Object


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/newsitem.rb', line 38

def self.from_params item
  n = Newsitem.new
  n.descr = item[:descr]
  n.username = item[:username]

  unless item[:report_id].blank?
    n.report = Report.find item[:report_id]
  end
  
  unless item[:gallery_id].blank?
    n.gallery = Gallery.find item[:gallery_id]
  end

  n.partial_name = item.partial_name unless item.partial_name.blank?

  return n
end

Instance Method Details


12
13
14
# File 'lib/newsitem.rb', line 12

def gallery
  self.gallery_id ? Gallery.unscoped.find( self.gallery_id ) : nil
end