mardi 7 janvier 2020

In Rails, what is the cleanest method of getting a variable name preferably in symbol form?

Suppose you have

[started, stopped].each do |action|
   # puts "#{action} is :started" # or
   # puts "#{action} is :stopped"
end

Getting the original variable name of the current item (action) I followed this answer https://stackoverflow.com/a/14074652/3577482, but it requires additional helper methods





Aucun commentaire:

Enregistrer un commentaire