{"comment":{"created_at":"2011-10-15T21:08:07Z","body":"Put that in lib/ in your rails app.","updated_at":"2011-10-15T21:08:07Z","url":"https://api.github.com/repos/mongoid/mongoid/issues/comments/2417792","id":2417792,"user":{"gravatar_id":"6f09262a13427532461b0b618d445b1e","avatar_url":"https://secure.gravatar.com/avatar/6f09262a13427532461b0b618d445b1e?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/durran","id":9030,"login":"durran"}},"action":"created","issue":{"number":1257,"created_at":"2011-09-16T11:02:45Z","pull_request":{"diff_url":null,"patch_url":null,"html_url":null},"body":"Hi guys, \r\nI have a many-to-many relation between products and categories. Here is the my models: \r\n\r\nclass Category\r\ninclude Mongoid::Document\r\nfield :name, :type => String\r\nhas_and_belongs_to_many :products, dependent: :nullify\r\nend\r\nclass Product\r\ninclude Mongoid::Document\r\nfield :name, :type => String\r\nfield :description, :type => String\r\nfield :price, :type => Integer\r\nhas_and_belongs_to_many :categories\r\nend\r\n\r\n\r\nI'm installed simple_form gem via bundler. But in view I get following errors: \r\n\r\nActionView::Template::Error (undefined method options for <Mongoid::Relations::Metadata:0xaeef070>):\r\n    27:     <%= f.label :category %>\r\n    28:   </div>\r\n    29:   <div class=\"field\">\r\n    30:     <%= f.association :categories %>\r\n    31:   </div>\r\n    32:   <div class=\"actions\">\r\n    33:     <%= f.submit %>\r\n  app/views/products/_form.html.erb:30:in block in _app_views_products__form_html_erb__313760580_89741420\r\n  app/views/products/_form.html.erb:1:in _app_views_products__form_html_erb__313760580_89741420\r\n  app/views/products/new.html.erb:3:in _app_views_products_new_html_erb__881899283_93020980\r\n  app/controllers/products_controller.rb:29:in new\r\n\r\nAnd here is the my view \r\n<%= simple_form_for(@product) do |f| %> \r\n  <div class=\"field\"> \r\n    <%= f.label :name %><br /> \r\n    <%= f.text_field :name %> \r\n  </div> \r\n  <div class=\"field\"> \r\n    <%= f.label :description %><br /> \r\n    <%= f.text_area :description %> \r\n  </div> \r\n  <div class=\"field\"> \r\n    <%= f.label :price %><br /> \r\n    <%= f.number_field :price %> \r\n  </div> \r\n  <div class=\"field\"> \r\n    <%= f.label :category %> \r\n  </div> \r\n  <div class=\"field\"> \r\n    <%= f.association :categories %> \r\n  </div> \r\n  <div class=\"actions\"> \r\n    <%= f.submit %> \r\n  </div> \r\n<% end %> \r\nPlease help me? Any idea? Sorry for poor English. \r\n","comments":3,"title":"mongoid, many-to-many relations","updated_at":"2011-10-15T21:08:07Z","url":"https://api.github.com/repos/mongoid/mongoid/issues/1257","id":1661299,"assignee":null,"milestone":null,"closed_at":"2011-09-16T11:28:12Z","user":{"gravatar_id":"3f7509c8eba74cc47cf51713f7980086","avatar_url":"https://secure.gravatar.com/avatar/3f7509c8eba74cc47cf51713f7980086?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/zolzaya","id":115309,"login":"zolzaya"},"html_url":"https://github.com/mongoid/mongoid/issues/1257","labels":[],"state":"closed"},"legacy":{"issue_id":1661299,"comment_id":2417792}}