Skip to content

Rails 3 support: active_model integration #3

Open
wants to merge 10 commits into from

4 participants

@galetahub

No description provided.

@skiz
Collaborator

:+1: This didn't exist when I backported the support.

@skiz
Collaborator
skiz commented Nov 9, 2011

There is already a (working) rails3 branch at https://github.com/jamesgolick/active_presenter/tree/rails3 However it looks like there are some good changes here. Would it be possible to apply your requested changes against that?

@skiz skiz commented on the diff Nov 9, 2011
@@ -1,22 +0,0 @@
@skiz
Collaborator
skiz added a note Nov 9, 2011

Removing licenses is a no-no.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@skiz skiz commented on the diff Nov 9, 2011
lib/active_presenter/base.rb
ActiveRecord::Base.transaction do
- if valid? && run_callbacks_with_halt(:before_save)
- saved = presented.keys.select {|key| save?(key, send(key))}.all? {|key| send(key).save}
- raise ActiveRecord::Rollback unless saved # TODO: Does this happen implicitly?
+ if !perform_validations?(options) || (perform_validations?(options) && valid?)
+ _run_save_callbacks do
@skiz
Collaborator
skiz added a note Nov 9, 2011

I am running in to a particular issue here where the after_save is being called within the transaction, so it will not be available for reading from other processes. Is there a way we can only call before_save within the transaction, then after_save outside the transaction?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.