I'm not sure if I missed something.

In the following case, when the join table is not a model, should it be 
possible to build the relation with nested attributes?

unless File.exist?('Gemfile')
  File.write('Gemfile', <<-GEMFILE)
    source 'https://rubygems.org'
    gem 'rails', github: 'rails/rails'
    gem 'arel', github: 'rails/arel'
    gem 'sqlite3'
  GEMFILE


  system 'bundle'
end


require 'bundler'
Bundler.setup(:default)


require 'active_record'
require 'minitest/autorun'
require 'logger'


# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 
':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)


ActiveRecord::Schema.define do
  create_table :posts, force: true  do |t|
  end


  create_table :tags, force: true  do |t|
  end


  create_table :post_tags, id: false, force: true  do |t|
    t.integer :post_id
    t.integer :tag_id
  end
end


class Post < ActiveRecord::Base
  has_and_belongs_to_many :tags
  accepts_nested_attributes_for :tags
end


class Tag < ActiveRecord::Base
end


class BugTest < Minitest::Test
  def test_habtm_nested_attributes
    post = Post.create!
    tag = Tag.create!
    post.tags_attributes = [{ tag_id: tag.id }]
    assert post.save
  end
end

Thanks

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to