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

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -