Ruby on rails 具有并属于多个模型变量名

Ruby on rails 具有并属于多个模型变量名,ruby-on-rails,Ruby On Rails,因此,我使用rails 4成功地将我的用户链接到了我的Products表,具体操作如下: users.rb has_and_belongs_to_many :products accepts_nested_attributes_for :products # Setup accessible (or protected) attributes for your model attr_accessible :email, :password, :password_confirmat

因此,我使用rails 4成功地将我的用户链接到了我的Products表,具体操作如下:

users.rb

  has_and_belongs_to_many :products
  accepts_nested_attributes_for :products
  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me, :role_ids, :product_ids
products.rb

has_and_belongs_to_many :users
view/userse/_form.html.erb

<%= simple_form_for(@user) do |f| %>
<%= f.association :products, label: "Product Release Email", value_method: :id, :as => :check_boxes %>
但是我得到了错误“uninitialized constant User::product”。所以我想我的一些参考资料是错的。

大写:

class_name: "Product"
class_name: "Product"