Created
July 19, 2017 14:48
-
-
Save viniciusnz/c3093ff73458be18caf575f36b4f120d to your computer and use it in GitHub Desktop.
This file contains 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
# for all options ended in _id, setup the instance variable for liquid | |
options.select{|k,v| k.to_s.ends_with?('_id')}.each do |k,v| | |
new_key = k.to_s.gsub(/_id\z/, '') | |
instance = Resource.resource_by_table_name(new_key.pluralize)&.model&.find_by(id: v) | |
if instance.present? | |
# puts ["@" + new_key, v] | |
instance_variable_set("@" + new_key, instance) | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment