Class: PagePart
- Inherits:
- 
      ActiveRecord::Base
      
        - Object
- ActiveRecord::Base
- PagePart
 
- Defined in:
- app/models/page_part.rb
Overview
defining model class to interact with database. It inherits the rails’s base class ActiveRecord::Base
Class Method Summary collapse
- 
  
    
      .delete_page_parts(page)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    : none. 
- 
  
    
      .find_page_parts_with_title(title)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    : array. 
- 
  
    
      .find_page_parts_with_title_main_body  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    : array. 
Class Method Details
.delete_page_parts(page) ⇒ Object
Returns : none.
| 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | # File 'app/models/page_part.rb', line 59 def self.delete_page_parts page # loop through page_parts_pages of page and check its page part page.page_parts_pages.each do |page_part_page| # find page_part by its id and assign it to a variable page_part = self.find_by_id(page_part_page.page_part_id) # if there is only one page_part for a page then delete it if page_part.pages.count == 1 and page_part.pages.first.title == page.title # delete page_part page_part.destroy end # end if end # end loop end | 
.find_page_parts_with_title(title) ⇒ Object
Returns : array.
| 34 35 36 37 38 39 40 41 42 43 44 45 | # File 'app/models/page_part.rb', line 34 def self.find_page_parts_with_title title #find all page parts with title header and assign it to a variable part_body = self.find_all_by_title(title) # calling method to find unique pages and assigning them to an array page_title = PagePartsPage.find_unique_page_parts_pages(part_body) # returning the array return page_title end | 
.find_page_parts_with_title_main_body ⇒ Object
Returns : array.
| 50 51 52 53 54 | # File 'app/models/page_part.rb', line 50 def self.find_page_parts_with_title_main_body return "main body" end |