ruby on rails - Select context dynamically -
in models have contexts like
acts_as_taggable_on :sport, :music in console can this
@student = student.first @student.sport_list = ("baseball, soccer") @student.save @student.music_list = ("rock, pop") @student.save @student.sport_list [baseball, soccer] @student.music_list [rock, pop] all works right but, in views want dynamic catch in 1 string context selected between others contexts javascript example:
mycontext = music my doubt is: possible make dynamic do
@student.mycontext_list = "rock, pop" because following error undefined method `mycontext_list=' student:0xb4475d4c
greetings friends!!!
try below:
@student.send :"#{mycontext}_list=", "rock, pop"
Comments
Post a Comment