Rails 3: Multiple Select with has_many through associations

后端 未结 5 2112
温柔的废话
温柔的废话 2020-11-27 11:24

I want to get possibility to select several Categories for one Post with multiple select.

I have next models: Post, Category and PostCategory.

class          


        
5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-27 11:50

    As the @post does not have id, the from might not display categories as there is no association. You need to pass do a build on @post something like

     @post = Post.new(:categories => Category.all)
    

提交回复
热议问题