Created
April 17, 2020 04:03
-
-
Save jambun/4ffcee180fb490dec60336ee8e7ee138 to your computer and use it in GitHub Desktop.
plausible?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.attach_raps(model_class, ids, rap) | |
objs = model_class.filter(:id => ids).all | |
jsons = model_class.sequel_to_jsonmodel(objs) | |
RAP.filter(:"#{model_class.table_name}_id" => ids).update(RAPs.supported_models.map {|model| [:"#{model.table_name}_id", nil]}.to_h) | |
objs.zip(jsons).each do |obj, json| | |
json['rap_attached'] = rap.to_hash | |
RAP.create_from_json(JSONModel(:rap).from_hash(rap), {:"#{obj.class.table_name}_id" => obj.id}) | |
obj.mark_as_system_modified | |
force_unpublish_for_restricted(model_class, obj.id) | |
end | |
end |
in fact don't need to be getting jsons and zipping anymore
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
line 8 is cruft