GithubHelp home page GithubHelp logo

Comments (4)

moiristo avatar moiristo commented on September 3, 2024

I'm not sure yet.. when you add a debugger after calling dup (before update_attribute), what does the object look like? Does it contain dups of all included data? The thing is that update_attribute might not do what you want. You should be calling save or update_attributes instead, as those methods will run callbacks.

from deep_cloneable.

atstockland avatar atstockland commented on September 3, 2024

You're right. The callback on either of those methods fails due to my own validations. Where as update_attribute was not.

I need to update that one attribute to pass a scoped uniqueness validation. How (when) would I update it?

Thanks for the gem!

Adam

On May 7, 2014, at 12:41 AM, Reinier de Lange [email protected] wrote:

I'm not sure yet.. when you add a debugger after calling dup (before update_attribute), what does the object look like? Does it contain dups of all included data? The thing is that update_attribute might not do what you want. You should be calling save or update_attributes instead, as those methods will run callbacks.


Reply to this email directly or view it on GitHub.

from deep_cloneable.

atstockland avatar atstockland commented on September 3, 2024

I apologize if this is an annoying question you get. Would you be willing to get online and take a peak at my implementation of this gem? I'd happily pay. This gem is a great way to dup...but, my model is somehow preventing things from working. adamstockland at gmail.

Adam

On May 7, 2014, at 12:41 AM, Reinier de Lange [email protected] wrote:

I'm not sure yet.. when you add a debugger after calling dup (before update_attribute), what does the object look like? Does it contain dups of all included data? The thing is that update_attribute might not do what you want. You should be calling save or update_attributes instead, as those methods will run callbacks.


Reply to this email directly or view it on GitHub.

from deep_cloneable.

moiristo avatar moiristo commented on September 3, 2024

First of all, I'd change the code to something like this:

course_copy = Course.find(2).dup(include: {:flightlessons => :scenarios})
course_copy.farpart = Farpart.find(1)
puts course_copy.errors.full_messages.to_sentence unless course_copy.valid? # some debugging
course_copy.save!

If it won't save while the copy is valid, then it might be the case that you've defined before_create or before_save callbacks in your models that return 'false', causing the save to fail.

from deep_cloneable.

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.