2012-12-30 175 views
1

我正在使用Rails Admin创业板。我有以下两种模式:Rails管理员和has_and_belongs_to_many

class Category < ActiveRecord::Base 
    attr_accessible :description, :name 

    has_and_belongs_to_many :experiences 
end 


class Experience < ActiveRecord::Base 
    attr_accessible :description, :city_id, :price, :title, :user_id 
    attr_accessible :categories 

    validates :title, :description, :user_id, :presence => true 

    belongs_to :user 
    belongs_to :city 
    has_and_belongs_to_many :categories 
end 

在Rails管理员中,我无法将类别添加到现有的体验中。在一个特定的经验的编辑网站,我看到:

Experience can't add category

正如你看到的,我不能选择任何类型,即使我已经创建了几个类别。

+0

在类别形式。你可以设置体验吗?或者只是在协会的一方? –

回答

3

它解决了通过添加以下到经验模型:的

attr_accessible :category_ids 

代替

attr_accessible :categories