title: Rails, association ids in one single cell with commas (not many rows in another table)
body: <p>I'm following this great cast:</p>
  
  <p><a href="http://railscasts.com/episodes/258-token-fields-revised" rel="nofollow">http://railscasts.com/episodes/258-token-fields-revised</a></p>
  
  <p>My database is <strong>Postgres</strong>.</p>
  
  <p>This schema:</p>
  
  <p><strong>author.rb</strong></p>
  
  <pre><code>class Author &lt; ActiveRecord::Base
    attr_accessible :name
    has_many :authorships
    has_many :books, through: :authorships
  
    def self.tokens(query)
      authors = where("name like ?", "%#{query}%")
      if authors.empty?
        [{id: "&lt;&lt;&lt;#{query}&gt;&gt;&gt;", name: "New: \"#{query}\""}]
      else
        authors
      end
    end
  
    def self.ids_from_tokens(tokens)
      tokens.gsub!(/&lt;&lt;&lt;(.+?)&gt;&gt;&gt;/) { create!(name: $1).id }
      tokens.split(',')
    end
  end
  </code></pre>
  
  <p><strong>authorship.rb</strong></p>
  
  <pre><code>class Authorship &lt; ActiveRecord::Base
    belongs_to :book
    belongs_to :author
  end
  </code></pre>
  
  <p><strong>book.rb</strong></p>
  
  <pre><code>class Book &lt; ActiveRecord::Base
    attr_accessible :name, :author_tokens
    has_many :authorships
    has_many :authors, through: :authorships
    attr_reader :author_tokens
  
    def author_tokens=(tokens)
      self.author_ids = Author.ids_from_tokens(tokens)
    end
  end
  </code></pre>
  
  <p>But I don't want to create the <strong>"authorship"</strong> table because of many rows! I want simply add in the book's table a column (string) with the author's ids, like this:</p>
  
  <p><strong>Books table</strong>:</p>
  
  <pre><code>    id    |    name    |    author_ids    
  -------------------------------------------
       1    |   Book A   |  15,12,16,19,2
       2    |   Book B   |  1,2,5,44,159,3
  </code></pre>
  
  <p>Is this possible?</p>