GithubHelp home page GithubHelp logo

Comments (4)

juggy avatar juggy commented on July 18, 2024

Hello,

The behavior is made to follow active record callbacks concept. Have a look at the first section:

http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html

Small change is that right now save callbacks are not called for update. There are some other bugs related to update I will share in a separate issue.

In your code example, you do not receive an instance to fooInstance. The whole callback in binded to the instance. So you can do this.bar etc.

Hope this answers your question. I think the readme should be updated to reflect this.

from jugglingdb.

mweibel avatar mweibel commented on July 18, 2024

Yeah, perfect. Thanks ;)

from jugglingdb.

1602 avatar 1602 commented on July 18, 2024

Hello, please check README (I've just updated it), section 'Object
lifecycle', it describes hooking functionality.

On Fri, Nov 18, 2011 at 2:39 PM, Michael Weibel <
[email protected]

wrote:

Hi,

could you please explain how to use those hooking functionalities?

Do I have to use it like that:

var foo = schema.define('foo', {
 bar: String
});

foo.beforeSave = function(fooInstance) {
 fooInstance.bar = fooInstance.bar + 'foobar';
}

Also I'm interested in hearing how the three mentioned correlate with each
other.. Is some e.g. beforeSave also called when updating/creating a row?

Thanks,
Michael


Reply to this email directly or view it on GitHub:
#6

Thanks,
Anatoliy Chakkaev

from jugglingdb.

mweibel avatar mweibel commented on July 18, 2024

Thanks :) It would be perfect if you'd fix the after/before save callbacks (called after the same way as in creating).

Maybe I'll dig a little bit into the code and can provide a patch for it..

from jugglingdb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.