GithubHelp home page GithubHelp logo

Comments (6)

moiristo avatar moiristo commented on September 3, 2024

deep_cloneable uses ActiveRecord#dup, which doesn't preserve timestamps (see http://apidock.com/rails/ActiveRecord/Core/dup). I think the best solution is to set it explicitly in the block, like you did with the picture_url.

from deep_cloneable.

ivendorin avatar ivendorin commented on September 3, 2024

Since I want to preserve the timestamp of raw_materials and costing_items which are nested , can you please show an example of how to do this ? Is it possible to set the nested attributes original and copy ?

from deep_cloneable.

ivendorin avatar ivendorin commented on September 3, 2024

It is not clear in the documentation as to how to set block for the association ? Kindly explain .

from deep_cloneable.

moiristo avatar moiristo commented on September 3, 2024

The block is called for every dup that has been made, even nested associations. That's why you need to check the type of the dup in the block.

from deep_cloneable.

ivendorin avatar ivendorin commented on September 3, 2024

What is the syntax to check the type ? I want to check for raw_materials association in the code

@costing = @old_costing.deep_clone :include => [{style: :images}, {raw_materials: :costing_items} , :other_cost_fixeds, :other_costs, :exchange_rates ], :use_dictionary => true do |original, kopy|
kopy.remote_picture_url = original.picture_url if kopy.is_a?(Image)
end

from deep_cloneable.

moiristo avatar moiristo commented on September 3, 2024

Something like this:

kopy.created_at = original.created_at if kopy.is_a? RawMaterial

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.