rtwomey/stately — pull request #12 by yokolet (2014-02-21 16:38:44+00:00)
Title: Fix for issue#11

Stately's write_attribute method overrides activerecord's write_attribute method. Because of this, stately and activerecords call write_attribute method each other, which causes stack level too deep error. This pull request changes the name, write_attribute, to write_state_attribute. After the change all tests passed. Also, I confirmed stately worked with activerecord using the example below:

```ruby
require 'active_record'
require 'protected_attributes'

class OrderModel < ActiveRecord::Base
establish_connection :adapter => 'sqlite3', :database => 'foobar.db'
connection.create_table table_name, :force => true do |t|
t.string :state
end

attr_accessible :state

stately :start => :processing do
state :completed do
prevent_from :refunded

before_transition :from => :processing, :do => :calculate_total
after_transition :do => :email_receipt

validate :validates_credit_card
end

state :invalid do
prevent_from :completed, :refunded
end

state :refunded do
allow_from :completed

after_transition :do => :email_receipt
end
end

def validates_credit_card
puts "everything is valid"
true
end

def calculate_total
puts "Total ?! I don't know"
-100
end

def email_receipt
puts "It should have emailed, I believe"
"You've gotten email!!!"
end
end
```

(used activerecord 4.0.2)

Additionally, this change adds attr_accessor to sample code in README.md. Without this (and a couple of methods implementation), the first example didn't work. It was confusing to me.