<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Ruby on Rails Finite State Machine Plugin: acts_as_state_machine</title>
	<link>http://rails.aizatto.com/2007/05/24/ruby-on-rails-finite-state-machine-plugin-acts_as_state_machine/</link>
	<description>Ruby and Ruby on Rails Development</description>
	<pubDate>Fri, 04 Jul 2008 13:21:12 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Ches</title>
		<link>http://rails.aizatto.com/2007/05/24/ruby-on-rails-finite-state-machine-plugin-acts_as_state_machine/#comment-847</link>
		<dc:creator>Ches</dc:creator>
		<pubDate>Fri, 23 May 2008 03:49:35 +0000</pubDate>
		<guid>http://rails.aizatto.com/2007/05/24/ruby-on-rails-finite-state-machine-plugin-acts_as_state_machine/#comment-847</guid>
		<description>@Stephen -
Why use an Observer? You can just send via an ActionMailer model -- or whatever else you need to do -- in a state change callback method. That's the type of thing they're there for :-) Example:

state :forgetful, :enter =&#62; :do_forgot_password

def do_forgot_password
  make_password_reset_code
  UserMailer.deliver_forgot_password(self)
end

@dkmenace -
I've been using acts_as_state_machine with 2.0.2 and Edge and haven't had problems.</description>
		<content:encoded><![CDATA[<p>@Stephen -<br />
Why use an Observer? You can just send via an ActionMailer model &#8212; or whatever else you need to do &#8212; in a state change callback method. That&#8217;s the type of thing they&#8217;re there for <img src='http://rails.aizatto.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> Example:</p>
<p>state :forgetful, :enter =&gt; :do_forgot_password</p>
<p>def do_forgot_password<br />
  make_password_reset_code<br />
  UserMailer.deliver_forgot_password(self)<br />
end</p>
<p>@dkmenace -<br />
I&#8217;ve been using acts_as_state_machine with 2.0.2 and Edge and haven&#8217;t had problems.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dkmenace</title>
		<link>http://rails.aizatto.com/2007/05/24/ruby-on-rails-finite-state-machine-plugin-acts_as_state_machine/#comment-840</link>
		<dc:creator>dkmenace</dc:creator>
		<pubDate>Tue, 20 May 2008 23:23:12 +0000</pubDate>
		<guid>http://rails.aizatto.com/2007/05/24/ruby-on-rails-finite-state-machine-plugin-acts_as_state_machine/#comment-840</guid>
		<description>Has anyone got this plugin working with Rails 2.0.X?</description>
		<content:encoded><![CDATA[<p>Has anyone got this plugin working with Rails 2.0.X?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephen</title>
		<link>http://rails.aizatto.com/2007/05/24/ruby-on-rails-finite-state-machine-plugin-acts_as_state_machine/#comment-824</link>
		<dc:creator>Stephen</dc:creator>
		<pubDate>Fri, 16 May 2008 22:00:31 +0000</pubDate>
		<guid>http://rails.aizatto.com/2007/05/24/ruby-on-rails-finite-state-machine-plugin-acts_as_state_machine/#comment-824</guid>
		<description>can you use an observer to log and/or mail out state changes when they occur, since they're not actual ActiveRecord hooks?</description>
		<content:encoded><![CDATA[<p>can you use an observer to log and/or mail out state changes when they occur, since they&#8217;re not actual ActiveRecord hooks?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick Poulden</title>
		<link>http://rails.aizatto.com/2007/05/24/ruby-on-rails-finite-state-machine-plugin-acts_as_state_machine/#comment-821</link>
		<dc:creator>Nick Poulden</dc:creator>
		<pubDate>Thu, 15 May 2008 09:40:10 +0000</pubDate>
		<guid>http://rails.aizatto.com/2007/05/24/ruby-on-rails-finite-state-machine-plugin-acts_as_state_machine/#comment-821</guid>
		<description>Thanks for this really useful article. I've been looking for some good documentation for this plugin for a while!</description>
		<content:encoded><![CDATA[<p>Thanks for this really useful article. I&#8217;ve been looking for some good documentation for this plugin for a while!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RAILroading &#187; Blog Archive &#187; links for 2008-05-06</title>
		<link>http://rails.aizatto.com/2007/05/24/ruby-on-rails-finite-state-machine-plugin-acts_as_state_machine/#comment-813</link>
		<dc:creator>RAILroading &#187; Blog Archive &#187; links for 2008-05-06</dc:creator>
		<pubDate>Tue, 06 May 2008 01:41:37 +0000</pubDate>
		<guid>http://rails.aizatto.com/2007/05/24/ruby-on-rails-finite-state-machine-plugin-acts_as_state_machine/#comment-813</guid>
		<description>[...] Ruby on Rails Finite State Machine Plugin: acts_as_state_machine » rails symphonies (tags: rubyonrails plugin) [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] Ruby on Rails Finite State Machine Plugin: acts_as_state_machine » rails symphonies (tags: rubyonrails plugin) [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tayfun</title>
		<link>http://rails.aizatto.com/2007/05/24/ruby-on-rails-finite-state-machine-plugin-acts_as_state_machine/#comment-692</link>
		<dc:creator>tayfun</dc:creator>
		<pubDate>Tue, 11 Mar 2008 13:43:38 +0000</pubDate>
		<guid>http://rails.aizatto.com/2007/05/24/ruby-on-rails-finite-state-machine-plugin-acts_as_state_machine/#comment-692</guid>
		<description>Oops, got the &#60; etc. stripped. Here it is in a better format:

&#62;&#62; person = Person.new
=&#62; #&#60;Person id: nil, state: nil, created_at: nil, updated_at: nil&#62;
&#62;&#62; person.shower!
NoMethodError: You have a nil object when you didn't expect it!

But,

&#62;&#62; person.state = 'working'
=&#62; "working"
&#62;&#62; person
=&#62; #&#60;Person id: nil, state: "working", created_at: nil, updated_at: nil&#62;
&#62;&#62; person.shower!
=&#62; true
&#62;&#62; person
=&#62; #&#60;Person id: 3, state: "sleeping", created_at: "2008-03-11 15:04:41", updated_at: "2008-03-11 15:04:41"&#62;

It's still sleeping in the end! So what I understand is that it doesn't matter what you do until the record is saved. It will still be initialized like it is defined no matter what events you call before. 

I guess in the end it's not good setting the default value through migrations like you say in the article. It will not matter when it is saved.

Good day.</description>
		<content:encoded><![CDATA[<p>Oops, got the &lt; etc. stripped. Here it is in a better format:</p>
<p>&gt;&gt; person = Person.new<br />
=&gt; #&lt;Person id: nil, state: nil, created_at: nil, updated_at: nil&gt;<br />
&gt;&gt; person.shower!<br />
NoMethodError: You have a nil object when you didn&#8217;t expect it!</p>
<p>But,</p>
<p>&gt;&gt; person.state = &#8216;working&#8217;<br />
=&gt; &#8220;working&#8221;<br />
&gt;&gt; person<br />
=&gt; #&lt;Person id: nil, state: &#8220;working&#8221;, created_at: nil, updated_at: nil&gt;<br />
&gt;&gt; person.shower!<br />
=&gt; true<br />
&gt;&gt; person<br />
=&gt; #&lt;Person id: 3, state: &#8220;sleeping&#8221;, created_at: &#8220;2008-03-11 15:04:41&#8243;, updated_at: &#8220;2008-03-11 15:04:41&#8243;&gt;</p>
<p>It&#8217;s still sleeping in the end! So what I understand is that it doesn&#8217;t matter what you do until the record is saved. It will still be initialized like it is defined no matter what events you call before. </p>
<p>I guess in the end it&#8217;s not good setting the default value through migrations like you say in the article. It will not matter when it is saved.</p>
<p>Good day.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tayfun</title>
		<link>http://rails.aizatto.com/2007/05/24/ruby-on-rails-finite-state-machine-plugin-acts_as_state_machine/#comment-691</link>
		<dc:creator>tayfun</dc:creator>
		<pubDate>Tue, 11 Mar 2008 13:11:01 +0000</pubDate>
		<guid>http://rails.aizatto.com/2007/05/24/ruby-on-rails-finite-state-machine-plugin-acts_as_state_machine/#comment-691</guid>
		<description>Many thanks for the enlightening article.

Here are some intricacies I believe I cannot describe well:

&#62;&#62; person = Person.new
=&#62; #
&#62;&#62; person.shower!
NoMethodError: You have a nil object when you didn't expect it!

But,

&#62;&#62; person.state = 'working'
=&#62; "working"
&#62;&#62; person
=&#62; #
&#62;&#62; person.shower!
=&#62; true
&#62;&#62; person
=&#62; #

It's still sleeping in the end! So what I understand is that it doesn't matter what you do until the record is saved. It will still be initialized like it is defined no matter what events you call before. 

I guess in the end it's not good setting the default value through migrations like you say in the article. It will not matter when it is saved.

Good day.</description>
		<content:encoded><![CDATA[<p>Many thanks for the enlightening article.</p>
<p>Here are some intricacies I believe I cannot describe well:</p>
<p>&gt;&gt; person = Person.new<br />
=&gt; #<br />
&gt;&gt; person.shower!<br />
NoMethodError: You have a nil object when you didn&#8217;t expect it!</p>
<p>But,</p>
<p>&gt;&gt; person.state = &#8216;working&#8217;<br />
=&gt; &#8220;working&#8221;<br />
&gt;&gt; person<br />
=&gt; #<br />
&gt;&gt; person.shower!<br />
=&gt; true<br />
&gt;&gt; person<br />
=&gt; #</p>
<p>It&#8217;s still sleeping in the end! So what I understand is that it doesn&#8217;t matter what you do until the record is saved. It will still be initialized like it is defined no matter what events you call before. </p>
<p>I guess in the end it&#8217;s not good setting the default value through migrations like you say in the article. It will not matter when it is saved.</p>
<p>Good day.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://rails.aizatto.com/2007/05/24/ruby-on-rails-finite-state-machine-plugin-acts_as_state_machine/#comment-664</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Wed, 27 Feb 2008 13:52:46 +0000</pubDate>
		<guid>http://rails.aizatto.com/2007/05/24/ruby-on-rails-finite-state-machine-plugin-acts_as_state_machine/#comment-664</guid>
		<description>First: Thanks to aizatto for that very nice explanation!
Very useful!

To Dave: Good point!  I think it's not good having just an empty array as the transition is not allowed. Any idea how to patch it in a separate "file" / plugin? (I'm very new to rails, so sorry for that "stupid" question.)

Greetz,
Chris</description>
		<content:encoded><![CDATA[<p>First: Thanks to aizatto for that very nice explanation!<br />
Very useful!</p>
<p>To Dave: Good point!  I think it&#8217;s not good having just an empty array as the transition is not allowed. Any idea how to patch it in a separate &#8220;file&#8221; / plugin? (I&#8217;m very new to rails, so sorry for that &#8220;stupid&#8221; question.)</p>
<p>Greetz,<br />
Chris</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://rails.aizatto.com/2007/05/24/ruby-on-rails-finite-state-machine-plugin-acts_as_state_machine/#comment-587</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Mon, 28 Jan 2008 18:07:47 +0000</pubDate>
		<guid>http://rails.aizatto.com/2007/05/24/ruby-on-rails-finite-state-machine-plugin-acts_as_state_machine/#comment-587</guid>
		<description>One potential gotcha is that invalid transitions return an empty array, rather than raise false or an exception.

For example:

state :fooish
state :barish
state :bazish

event :bar do
transitions :from =&#62; :fooish, :to =&#62; :bar
end

something.state = 'baz'
something.bar! #=&#62; []

A quick monkey patch would overload Event::fire(record):

          def fire(record)
            next_states = next_states(record) # line added
            return false if next_states.empty? # line added
            next_states.each do &#124;transition&#124; # line edited
              break true if transition.perform(record)
            end
          end

something.state = 'baz'
something.bar! #=&#62; false

D</description>
		<content:encoded><![CDATA[<p>One potential gotcha is that invalid transitions return an empty array, rather than raise false or an exception.</p>
<p>For example:</p>
<p>state :fooish<br />
state :barish<br />
state :bazish</p>
<p>event :bar do<br />
transitions :from =&gt; :fooish, :to =&gt; :bar<br />
end</p>
<p>something.state = &#8216;baz&#8217;<br />
something.bar! #=&gt; []</p>
<p>A quick monkey patch would overload Event::fire(record):</p>
<p>          def fire(record)<br />
            next_states = next_states(record) # line added<br />
            return false if next_states.empty? # line added<br />
            next_states.each do |transition| # line edited<br />
              break true if transition.perform(record)<br />
            end<br />
          end</p>
<p>something.state = &#8216;baz&#8217;<br />
something.bar! #=&gt; false</p>
<p>D</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sau Sheong</title>
		<link>http://rails.aizatto.com/2007/05/24/ruby-on-rails-finite-state-machine-plugin-acts_as_state_machine/#comment-577</link>
		<dc:creator>Sau Sheong</dc:creator>
		<pubDate>Sun, 27 Jan 2008 05:41:03 +0000</pubDate>
		<guid>http://rails.aizatto.com/2007/05/24/ruby-on-rails-finite-state-machine-plugin-acts_as_state_machine/#comment-577</guid>
		<description>Hi Adam,

This plugin maps a finite state machine. I think you should draw out your state diagram first and see how you want to transit from one state to another. You sound as if you want to have multiple initial states. Things should be much clearer with a  state diagram. Hope this helps.</description>
		<content:encoded><![CDATA[<p>Hi Adam,</p>
<p>This plugin maps a finite state machine. I think you should draw out your state diagram first and see how you want to transit from one state to another. You sound as if you want to have multiple initial states. Things should be much clearer with a  state diagram. Hope this helps.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
