pahanix / delegates_attributes_to Goto Github PK
View Code? Open in Web Editor NEWA rails plugin to allow delegation to ActiveRecord associations with dirty check and auto saving.
A rails plugin to allow delegation to ActiveRecord associations with dirty check and auto saving.
I was wondering why item.attribute? (in the example, this would be u.firstname?) is not delegated.
in the example, you can delegate u.contact.firstname to u.firstname, but u.contact.firstname? is not delegated.
After a quick look in the code, all that needs to be done to support this is adding '?' to the ATTRIBUTE_SUFFIXES array.
changed? is misspelled.
u.profile.about = "Bob"
u.chaged? # => true
u = User.last
u.chaged? # => false
On at least Rails 3.2.8 using this gem results in the following exception when saving a model:
NoMethodError: private method `changed_attributes' called for #ModelClassName:instance
The visibility of #changed_attributes is inadvertently set to private by this gem and must instead be public as per ActiveRecord::Dirty
Using this monkey patch to force visibility of #changed_attributes to public again rectifies the problem:
class ActiveRecord::Base
public :changed_attributes
end
Currently, you cannot assign date or time attributes through delegates_attributes_to.
It raises MultiparameterAssignmentErrors in execute_callstrack_for_multiparameter_attributes because it unable to determine the klass on line 3044.
column_for_attribute needs to be smarter and look up the attribute on the delegate object.
This is with ActiveRecord 2.3.5.
Seems like "loaded_#{association}?" is not defined in Rails 3.1... not sure what the replacement is.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.