einzige / sneaky-save

Allows to update complex objects without triggering validations or callbacks.
46 stars 31 forks source link

Cannot save with associated objects #8

Closed cis-venkat closed 10 years ago

cis-venkat commented 10 years ago

Nice one! But, I have tried to save an object that has some associated objects build. When I do obj.sneaky_save, only obj get saved but not associated ones. Is there any way to do this?

einzige commented 10 years ago

https://github.com/einzige/sneaky-save/blob/master/lib/sneaky-save.rb#L10

einzige commented 10 years ago

It uses only native SQL queries, no callbacks. That was the main reason of creating this gem.

akshayrawat commented 10 years ago

Perhaps we are missing some README on this.

sneaky_save only saves the current record, not its associations. Which means that if you have any updated belongs_to foreign key attributes on that record they would be saved.

Its kinda risky and out of scope to do a recursive save (via has_many etc), as you might end up pulling your ending database.

cis-venkat commented 10 years ago

It sounds like intentional. Great Thanks!