Module: SimplyTrackable::ARMethods

Defined in:
lib/simply_trackable/simply_trackable.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_trackable(options = {}) ⇒ Object Also known as: simply_trackable



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/simply_trackable/simply_trackable.rb', line 7

def acts_as_trackable(options = {})
	has_many	:tracks, :as => :trackable, :dependent => :destroy
#			validates_length_of :tracking_number, :minimum => 3
	validates_uniqueness_of :tracking_number,
		:allow_blank => true

	if self.accessible_attributes
		attr_accessible :tracking_number
	end

	include SimplyTrackable::InstanceMethods

	before_validation :nullify_blank_tracking_number

end