我正在使用http://www.youtube.com/watch?v=PUHmX18Zmyk视频制作博客。我的帖子模型是
class Post < ActiveRecord::Base
attr_accessible :body, :publish_date, :title, :user_id
validates_presence_of :title, :body, :publish_date, :user_id
belongs_to :user
has_and_belongs_to_many :categories
end
类别模型是
class Category < ActiveRecord::Base
attr_accessible :name
validates_presence_of :name
has_and_belongs_to_many :posts
end
在视频中,他使用此类代码在新帖子中生成类别列表
<% f.association :categories, :as => :checkboxes %>
但我有错误
undefined method `association' for #<ActionView::Helpers::FormBuilder:0xb5e82b40>
制作类别列表的正确方法是什么?