troessner/transitions — pull request #68 by simonc (2013-01-18 17:00:09+00:00)
Title: Problem with initial_state and mongoid

Using mongoid (v3.0.17) I have an issue with the initial state setting.

``` ruby
product = Product.new
product.current_state #=> :available
product.valid? #=> false
product.errors #=> ... {:state=>["can't be blank", "is not included in the list"]}
```

`ActiveModel#Transitions.set_initial_state` tests for `has_attribute?(:state)`.

``` ruby
self.state ||= self.class.get_state_machine.initial_state.to_s if self.has_attribute?(:state)
```

Mongoid returns `false` if the field is not set. Maybe it should only check `respond_to?(:state=)` don't you think ?