Class: Album

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.page(search, page) ⇒ Object



9
10
11
# File 'app/models/album.rb', line 9

def self.page(search, page)
with_permissions_to(:manage).search(search).order("title").paginate(:per_page => 10, :page => page)
end

.search(search) ⇒ Object



13
14
15
16
17
18
19
# File 'app/models/album.rb', line 13

def self.search(search)
  if search
    where("title LIKE ?", "%#{search}%")
  else
    scoped
  end
end

Instance Method Details

#create_menu_itemObject



39
40
41
42
43
44
45
46
# File 'app/models/album.rb', line 39

def create_menu_item
	@menu_item = self.build_menu_item(
		:title => self.title,
		:url => "/photos-for/#{self.filename}",
		:active => self.active
	)
	@menu_item.save
end

#update_menu_itemObject



26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/models/album.rb', line 26

def update_menu_item
	@menu_item = self.menu_item
	if @menu_item == nil
		self.create_menu_item
	else
	@menu_item.update_attributes(	
			:title => self.title,
			:url => "/photos-for/#{self.filename}",
			:active => self.active
	)
	end
end