updated docs
This commit is contained in:
parent
a0bb1c404c
commit
277373b41a
|
@ -1,5 +1,7 @@
|
||||||
* Specs and bug fixes for the ActiveRecordPersistence, keeping persistence columns in sync
|
* Specs and bug fixes for the ActiveRecordPersistence, keeping persistence columns in sync
|
||||||
Allowing for nil values in states for active record
|
Allowing for nil values in states for active record
|
||||||
|
Only set state to default state before_validation_on_create
|
||||||
|
New rake task to uninstall, build and reinstall the gem (useful for development)
|
||||||
New non-(!) methods that allow for firing events without persisting [Jeff Dean]
|
New non-(!) methods that allow for firing events without persisting [Jeff Dean]
|
||||||
|
|
||||||
* Added aasm_states_for_select that will return a select friendly collection of states.
|
* Added aasm_states_for_select that will return a select friendly collection of states.
|
||||||
|
|
9
Rakefile
9
Rakefile
|
@ -82,4 +82,13 @@ else
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if !defined?(Gem)
|
||||||
|
puts "Package target requires RubyGEMs"
|
||||||
|
else
|
||||||
|
desc "sudo gem uninstall aasm && rake gem && sudo gem install pkg/aasm-3.0.0.gem"
|
||||||
|
task :reinstall do
|
||||||
|
puts `sudo gem uninstall aasm && rake gem && sudo gem install pkg/aasm-3.0.0.gem`
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
task :default => [:spec]
|
task :default => [:spec]
|
||||||
|
|
|
@ -11,6 +11,10 @@ module AASM
|
||||||
# * WriteState
|
# * WriteState
|
||||||
# * WriteStateWithoutPersistence
|
# * WriteStateWithoutPersistence
|
||||||
#
|
#
|
||||||
|
# Adds
|
||||||
|
#
|
||||||
|
# before_validation_on_create :aasm_ensure_initial_state
|
||||||
|
#
|
||||||
# As a result, it doesn't matter when you define your methods - the following 2 are equivalent
|
# As a result, it doesn't matter when you define your methods - the following 2 are equivalent
|
||||||
#
|
#
|
||||||
# class Foo < ActiveRecord::Base
|
# class Foo < ActiveRecord::Base
|
||||||
|
@ -94,13 +98,20 @@ module AASM
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Called from before_validation_on_create to ensure
|
# Ensures that if the aasm_state column is nil and the record is new
|
||||||
# that if there is a nil value in the underlying aasm_state
|
# that the initial state gets populated before validation on create
|
||||||
# column, the initial state is used instead
|
|
||||||
#
|
#
|
||||||
# foo = Foo.new
|
# foo = Foo.new
|
||||||
# foo.save
|
# foo.aasm_state # => nil
|
||||||
# foo.aasm_state # => the initial state
|
# foo.valid?
|
||||||
|
# foo.aasm_state # => "open" (where :open is the initial state)
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# foo = Foo.find(:first)
|
||||||
|
# foo.aasm_state # => 1
|
||||||
|
# foo.aasm_state = nil
|
||||||
|
# foo.valid?
|
||||||
|
# foo.aasm_state # => nil
|
||||||
#
|
#
|
||||||
def aasm_ensure_initial_state
|
def aasm_ensure_initial_state
|
||||||
send("#{self.class.aasm_column}=", self.aasm_current_state.to_s)
|
send("#{self.class.aasm_column}=", self.aasm_current_state.to_s)
|
||||||
|
|
Loading…
Reference in New Issue