Class: Template

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
ActionController::UrlWriter, ActionView::Helpers::AssetTagHelper, ActionView::Helpers::JavaScriptHelper, ActionView::Helpers::TagHelper, ActionView::Helpers::TextHelper, ERB::Util
Defined in:
app/models/template.rb

Overview

Schema Information

Table name: templates

 id                   :integer(4)      not null, primary key
 title                :string(255)
 code                 :text
 type                 :string(255)
 deleted_at           :datetime
 created_at           :datetime
 updated_at           :datetime
 content_element_type :string(255)

Direct Known Subclasses

ContentElementTemplate, PageTemplate

Constant Summary

ALLOCATED_TAGS =
["content_for_layout"]

Instance Method Summary

Instance Method Details

- (Object) actions



34
35
36
37
38
39
40
41
# File 'app/models/template.rb', line 34

def actions
  actions = link_to_remote( image_tag("icons/edit.png") , 
                                :url => { :controller => "admin/"+self.class.to_s.tableize, :action => "edit", :id => id, :only_path => true  }, 
                                :method => "get")
  actions << link_to_remote( image_tag("icons/delete.png") , 
                                :url => { :controller => "admin/"+self.class.to_s.tableize, :action => "destroy", :id => id, :only_path => true  }, 
                                :method => "delete")
end

- (Object) clean_code

returns a html escaped code with a maximum of 60 chars



44
45
46
# File 'app/models/template.rb', line 44

def clean_code
  truncate(html_escape(code), :length => 60, :omission => "...")
end