Class: ArDesign
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- ArDesign
- Defined in:
- app/models/ar_design.rb
Overview
Schema information
Table name: ar_design : Designs
id Integer id created_at Time created_at updated_at Time updated_at description String Short description of design body String Body of design which will be rendered like any Rails view params String Parameters used by design css String CSS for design rails_view String Rails view (file) name which will be used to render design code String Ruby code evaluated when processing page author String Creater if design active Boolean Is the design active created_by Integer created_by updated_by Integer Last updated by site_id Integer Select site name if this design belongs to singe site
Designs are essential parts of AgileRails. Every ArPage document must have its design document defined. If ArPage documents are anchors for url addresses, ArDesign documents define how will page data be rendered in browser.
ArDesign documents define what would normally be written into Rails view file. The code is saved in the body field of ArDesign document. If you prefere Rails way, enter view file name into rails_view field and put your code into file into views directory (ex. designs/home_page for ../views/designs/home_page.html.erb file).
If you choose to save code to Rails view file you must add one top and bottom line to every source file. Top line will provide CMS edit menu, bottom line will provide additional CSS and javascript code scooped when renderers are called.
Example (as written in body of ar_design):
<div id="site">
<div id="site-top-bg">
<div id="site-top"><div id="logo"><%= agile_render(:ar_piece, name: 'site-top') %></div>
<div id="login"><%= agile_render(:common, method: 'login') %></div>
</div>
<%= agile_render(:ar_menu, name: 'test-menu') %>
</div>
<div id="page"><%= agile_render(:ar_page) %></div>
</div>
<div id="site-bottom"><%= agile_render(:ar_piece, name: 'site-bottom') %></div>
Example (as written in Rails view file):
<%= render partial: 'ra/edit_stuff' if session > 0 %>
<div id="page"><%= agile_render(:ar_page) %></div>
</div>
<div id="site-bottom"><%= agile_render(:ar_piece, name: 'site-bottom') %></div>
<%= javascript_tag @js %>
Class Method Summary collapse
-
.choices_for_designs(site = nil) ⇒ Object
Return choices for select for design_id.
Instance Method Summary collapse
-
#cache_clear ⇒ Object
Clear cache if cache is configured.
Class Method Details
.choices_for_designs(site = nil) ⇒ Object
Return choices for select for design_id.
If site is passed as parameter, only designs which belong to site or do not have site assigned will be selected. Too much designs to select often confuses end user.
110 111 112 113 114 |
# File 'app/models/ar_design.rb', line 110 def self.choices_for_designs(site = nil) site.nil? ? where(active: true) : where(site_id: [nil, site.id], active: true) .sort { |w1, w2| w1.description.casecmp(w2.description) } .map { |design| [design.description, design.id] } end |
Instance Method Details
#cache_clear ⇒ Object
Clear cache if cache is configured
99 100 101 |
# File 'app/models/ar_design.rb', line 99 def cache_clear Agile.cache_clear(:ar_design) end |