Class: PagePartsPage

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

Overview

defining model class to interact with database. It inherits the rails’s base class ActiveRecord::Base

Class Method Summary collapse

Class Method Details

.find_unique_page_parts_pages(parts) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/models/page_parts_page.rb', line 31

def self.find_unique_page_parts_pages(parts)

  #initialize an empty array
  page_title = Hash.new
  
  # for each parts
  parts.each do |part|

    #find first page id using the page_part part
    page_parts_pages = self.find_by_page_part_id(part.id)

    # insert page title in the array
    page_title[page_parts_pages.page_part.id] = page_parts_pages.page.title if not page_parts_pages.nil?
    
  end # end loop

  # return array of page title
  return page_title

end