Module: ActsAsViewable::InstanceMethods
- Defined in:
- lib/acts_as_viewable/acts_as_viewable.rb
Instance Method Summary collapse
Instance Method Details
#view!(ip) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/acts_as_viewable/acts_as_viewable.rb', line 26 def view!(ip) unless Viewing.create(:viewable_id => id, :viewable_type => self.class.name, :ip => ip).new_record? if total_viewings total_viewings.increment!(:viewings) else create_total_viewings(:viewable_type => self.class.name, :viewings => 1) end end end |
#views ⇒ Object
22 23 24 |
# File 'lib/acts_as_viewable/acts_as_viewable.rb', line 22 def views total_viewings && total_viewings.viewings || 0 end |