Class: ActiveRecord::Base

Inherits:
Object show all
Defined in:
lib/commonthread/monkey_patches.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](id) ⇒ Object



161
162
163
# File 'lib/commonthread/monkey_patches.rb', line 161

def self.[](id)
	self.find(id)
end

Instance Method Details

#dom_id(prefix = nil) ⇒ Object



173
174
175
176
# File 'lib/commonthread/monkey_patches.rb', line 173

def dom_id(prefix = nil) 
	prefix ||= 'new' if self.new_record? 
	[ prefix, self.class.name, self.id ].compact.join('_').downcase
end

#to_paramObject



165
166
167
168
169
170
171
# File 'lib/commonthread/monkey_patches.rb', line 165

def to_param
	if self.respond_to?(:name) and !self.name.blank?
		"#{self.id}-#{self.name.to_pretty_url}"
	else
		self.id.to_s
	end
end