Class: Layout
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Layout
- Defined in:
- app/models/layout.rb
Overview
defining model class to interact with database. It inherits the rails’s base class ActiveRecord::Base
Class Method Summary collapse
-
.find_all_layouts ⇒ Object
: Array.
-
.find_page_parts(layout_id) ⇒ Object
: Array.
Class Method Details
.find_all_layouts ⇒ Object
Returns : Array.
33 34 35 36 37 38 |
# File 'app/models/layout.rb', line 33 def self.find_all_layouts # finding all layouts from the DB and return the array return self.select("id, name"); end |
.find_page_parts(layout_id) ⇒ Object
Returns : Array.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/models/layout.rb', line 43 def self.find_page_parts layout_id #initializing an array with some default value page_part_array = [] # finding the layout with given id layout = self.find_by_id(layout_id) # check and include page part in page part array if page part value is # true in DB page_part_array << "header" if layout["header"] page_part_array << "footer" if layout["footer"] page_part_array << "left body" if layout["lft"] page_part_array << "right body" if layout["rgt"] page_part_array << "main body" if layout["main"] # return the array return page_part_array end |