Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in ParseResource::Base#save #125

Open
joshuabowers opened this issue May 21, 2014 · 1 comment
Open

Bug in ParseResource::Base#save #125

joshuabowers opened this issue May 21, 2014 · 1 comment

Comments

@joshuabowers
Copy link

The explicit returns in save are causing the method to exit before returning control back to run_callbacks. This is, in turn, canceling any around_save and after_save callbacks which might be defined on the class. This can be fixed by simply removing the return statements.

In case this doesn't get updated, and others stumble across this problem, you can monkey patch a workaround for this something like the following:

class ParseResource::Base
  self.send(:alias_method, :_original_save, :save)

  def save
    if valid?
      run_callbacks :save do
        if new?
          create
        else
          update
        end
      end
    else
      false
    end
  rescue
    false
  end
end

If you are using this in Rails, you can throw this in an initializer to override the default behavior.

@sbonami
Copy link
Contributor

sbonami commented May 31, 2014

Hey @joshuabowers, feel free to push up a pull request and we can get this merged.

kranzky added a commit to RobotsandRockets/parse_resource that referenced this issue Aug 19, 2015
this was preventing an `after_save` hook from running

ref: adelevie#125

GFM-303 #time 30m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants