Sha256: 1bb94be2f9173d9d651345bdd7d7fe45765e897b7f0ec58a8f0f387470593d37
Contents?: true
Size: 675 Bytes
Versions: 15
Compression:
Stored size: 675 Bytes
Contents
class MetaTag < ::ActiveRecord::Base belongs_to :taggable, :polymorphic => true validates_presence_of :name, :taggable_type validates_uniqueness_of :name, :scope => [:taggable_type, :taggable_id, :is_dynamic] attr_accessible :name, :content, :is_dynamic def get_content(controller=nil) self.is_dynamic ? dynamic_content(controller) : self.content end def dynamic_content(controller) self.content.gsub /%{([\w\.]+)}/ do items = $1.split('.') instance_name = items.shift method_name = items.join('.') record = controller.instance_variable_get("@#{instance_name}") record.try(:"#{method_name}") end end end
Version data entries
15 entries across 11 versions & 2 rubygems