在我的模型有背景喜歡選擇方面動態
acts_as_taggable_on :sport, :music
在控制檯中我能做到這一點
@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]
所有這些作品的權利,但是,在視圖中我想這樣做動態 我在一個字符串中捕獲通過JavaScript在其他上下文之間選擇的上下文,例如:
mycontext = music
我的疑問是:它可以進行動態做
@student.mycontext_list = "rock, pop"
,因爲我碰到下面的錯誤未定義的方法`mycontext_list =」的學生:0xb4475d4c
問候朋友!
senk你了! 100%有用 –