You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support ActiveRecord models with composite primary keys #291
When super_diff encounters a model with a composite primary key, it raises an error, undefined method 'to_sym' for an instance of Array.
Preferably it would correctly support composite primary keys, but not erroring would be an improvement.
Poking around in the code, it appears that building on #237 and #282 would be a reasonable approach. A majority of the work might be in setting up the testing environment. I tweaked attributes_for_super_diff locally and was able to eliminate the error I saw with the implementation below. This change does not break any existing tests. Similar methodology can likely be used elsewhere.
classActiveRecord::Base# TODO: Remove this monkey patch if possibledefattributes_for_super_diffid_attrs=Array.wrap(self.class.primary_key)(attributes.keys.sort - id_attrs).reduce(attributes.slice(*id_attrs).symbolize_keys){ |hash,key| hash.merge(key.to_sym=>attributes[key])}endend
Activity