views:

24

answers:

0

How should the keyword_list=(value) method look ?

class Keyword < ActiveRecord::Base
  belongs_to :keywordable, :polymorphic => true
end

class Article < ActiveRecord::Base
  has_many :keywords, :as => :keywordable

  #getter
  def keyword_list
    keywords.map {|keyword| keyword.name + ","}.to_s.chop
  end

  #setter
  def keyword_list=(string_of_keywords)
    #how I can set the association here ?
  end
end