0
我有兩個班,我想建立一個多到許多assications,這裏是代碼:建立在Ruby中許多-to-many關聯on Rails的
class Category < ActiveRecord::Base
has_and_belongs_to_many :events
has_and_belongs_to_many :tips
end
class Tip < ActiveRecord::Base
has_and_belongs_to_many :categories
不過,我一直得到以下錯誤,我會很感激,如果有人能教我什麼錯誤:
PGError: ERROR: relation "categories_tips" does not exist
: SELECT "categories".id FROM "categories" INNER JOIN "categories_tips" ON "categories".id = "categories_tips".category_id WHERE ("categories_tips".tip_id = NULL)
the viewer part:
4: <%= text_field :tip, :title %></label></p>
5:
6: <p><label>Categories<br/>
7: <%= select_tag('categories[]', options_for_select(Category.find(:all).collect {|c| [c.name, c.id] }, @tip.category_ids), :multiple => true) %></label></p>
8:
9: <p><label>Location<br/>
10: <%= text_field_with_auto_complete :tip, :abstract %></label></p>
是的......非常感謝! – john 2010-06-10 01:28:59