Class: DogEars::Bookmark

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/dog_ears/bookmark.rb

Constant Summary collapse

LEVELS =

attr_accessible :title, :body

['none', 'info', 'success', 'warning', 'important']

Class Method Summary collapse

Class Method Details

.count_by_levelsObject



15
16
17
18
19
20
21
# File 'app/models/dog_ears/bookmark.rb', line 15

def self.count_by_levels
  cbl = group(:level).count
  LEVELS.inject({}) do |a,e|
    a[e] = cbl[e] if cbl[e] && cbl[e] > 0
    a
  end
end

.for_user_and_path(user, path) ⇒ Object



11
12
13
# File 'app/models/dog_ears/bookmark.rb', line 11

def self.for_user_and_path(user,path)
  for_user(user).where(path: path).first
end