lib/hobo/lifecycles/transition.rb in hobo-0.8.10 vs lib/hobo/lifecycles/transition.rb in hobo-0.9.0
- old
+ new
@@ -18,14 +18,22 @@
lifecycle.transitions << self
end
def extract_attributes(attributes)
- update_attributes = options.fetch(:params, [])
- attributes & update_attributes
+ model = lifecycle.model
+ params = options.fetch(:params, [])
+ allowed = params.dup
+ params.each do |p|
+ if (refl = model.reflections[p]) && refl.macro == :belongs_to
+ allowed << refl.primary_key_name.to_s
+ allowed << refl.options[:foreign_type] if refl.options[:polymorphic]
+ end
+ end
+ attributes & allowed
end
-
-
+
+
def change_state(record)
record.lifecycle.become(get_state(record, end_state))
end