Skip to content

Instantly share code, notes, and snippets.

@gmcinnes
Created September 20, 2012 01:10
Show Gist options
  • Save gmcinnes/3753390 to your computer and use it in GitHub Desktop.
Save gmcinnes/3753390 to your computer and use it in GitHub Desktop.
resource_fieldname = field.keys.first
resource_field = @resource.send(resource_fieldname)
resource_field_value = field.values.first
target = resource_field[resource_field_value]
# This if you don't care what it becomes if it's not an array previously
#target = agent.id if target.is_a? Array
# This if you always want it to end up as an array, even if it wasn't previously
#target = agent.id rescue target = []
target.save
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment