<?xml version="1.0" encoding="UTF-8"?>
<ticket>
  <assigned-user-id type="integer">5609</assigned-user-id>
  <attachments-count type="integer">2</attachments-count>
  <closed type="boolean">true</closed>
  <created-at type="datetime">2008-07-26T18:56:51-05:00</created-at>
  <creator-id type="integer">26603</creator-id>
  <milestone-due-on type="datetime" nil="true"></milestone-due-on>
  <milestone-id type="integer" nil="true"></milestone-id>
  <number type="integer">485</number>
  <permalink>has-n-through-does-not-allow-saving-of-model</permalink>
  <priority type="integer">15665</priority>
  <project-id type="integer">20609</project-id>
  <raw-data type="binary" nil="true" encoding="base64"></raw-data>
  <state>resolved</state>
  <tag>associations dm-core has_and_belongs_to_many</tag>
  <title>&quot;has n, :through...&quot; does not allow saving of model</title>
  <updated-at type="datetime">2009-05-28T03:27:19-05:00</updated-at>
  <user-id type="integer">5609</user-id>
  <user-name>Dan Kubb (dkubb)</user-name>
  <creator-name>Bobby Calderwood</creator-name>
  <assigned-user-name>Dan Kubb (dkubb)</assigned-user-name>
  <url>http://datamapper.lighthouseapp.com/projects/20609/tickets/485</url>
  <original-body>&lt;pre&gt;&lt;code&gt;
class Taggable
include DataMapper::Resource
property :id, Integer, :serial =&gt; true
has n, :taggings
has n, :tags, :through =&gt; :taggings
end

class Tagging
include DataMapper::Resource
property :id, Integer, :serial =&gt; true
belongs_to :taggable
belongs_to :tag
end

class Tag
include DataMapper::Resource
property :id, Integer, :serial =&gt; true
has n, :taggings
has n, :taggables, :through =&gt; :taggings
end

taggable = Taggable.new
taggable.tags
taggable.save
&lt;/code&gt;&lt;/pre&gt;

Trying to access the remote association and then saving raises this strange error:

&lt;pre&gt;
DataMapper::Associations::ImmutableAssociationError: You can not modify this assocation
	from /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/associations/one_to_many.rb:247:in `assert_mutable'
	from /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/associations/one_to_many.rb:199:in `save'
	from /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/resource.rb:272:in `hookable__save_nan_before_advised'
	from /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/resource.rb:272:in `each'
	from /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/resource.rb:272:in `hookable__save_nan_before_advised'
	from /Library/Ruby/Gems/1.8/gems/extlib-0.9.3/lib/extlib/hook.rb:294:in `save!'
	from /Library/Ruby/Gems/1.8/gems/extlib-0.9.3/lib/extlib/hook.rb:292:in `catch'
	from /Library/Ruby/Gems/1.8/gems/extlib-0.9.3/lib/extlib/hook.rb:292:in `save!'
	from /Library/Ruby/Gems/1.8/gems/dm-validations-0.9.3/lib/dm-validations.rb:44:in `save'
	from (irb):39
&lt;/pre&gt;</original-body>
  <latest-body>&lt;pre&gt;&lt;code&gt;
class Taggable
include DataMapper::Resource
property :id, Integer, :serial =&gt; true
has n, :taggings
has n, :tags, :through =&gt; :taggings
end

class Tagging
include DataMapper::Resource
property :id, Integer, :serial =&gt; true
belongs_to :taggable
belongs_to :tag
end

class Tag
include DataMapper::Resource
property :id, Integer, :serial =&gt; true
has n, :taggings
has n, :taggables, :through =&gt; :taggings
end

taggable = Taggable.new
taggable.tags
taggable.save
&lt;/code&gt;&lt;/pre&gt;

Trying to access the remote association and then saving raises this strange error:

&lt;pre&gt;
DataMapper::Associations::ImmutableAssociationError: You can not modify this assocation
	from /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/associations/one_to_many.rb:247:in `assert_mutable'
	from /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/associations/one_to_many.rb:199:in `save'
	from /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/resource.rb:272:in `hookable__save_nan_before_advised'
	from /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/resource.rb:272:in `each'
	from /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/resource.rb:272:in `hookable__save_nan_before_advised'
	from /Library/Ruby/Gems/1.8/gems/extlib-0.9.3/lib/extlib/hook.rb:294:in `save!'
	from /Library/Ruby/Gems/1.8/gems/extlib-0.9.3/lib/extlib/hook.rb:292:in `catch'
	from /Library/Ruby/Gems/1.8/gems/extlib-0.9.3/lib/extlib/hook.rb:292:in `save!'
	from /Library/Ruby/Gems/1.8/gems/dm-validations-0.9.3/lib/dm-validations.rb:44:in `save'
	from (irb):39
&lt;/pre&gt;</latest-body>
  <original-body-html>&lt;div&gt;&lt;p&gt;
class Taggable
&lt;/p&gt;&lt;p&gt;
include DataMapper::Resource
&lt;/p&gt;&lt;p&gt;
property :id, Integer, :serial =&gt; true
&lt;/p&gt;&lt;p&gt;
has n, :taggings
&lt;/p&gt;&lt;p&gt;
has n, :tags, :through =&gt; :taggings
&lt;/p&gt;&lt;p&gt;
end
&lt;/p&gt;&lt;p&gt;
class Tagging
&lt;/p&gt;&lt;p&gt;
include DataMapper::Resource
&lt;/p&gt;&lt;p&gt;
property :id, Integer, :serial =&gt; true
&lt;/p&gt;&lt;p&gt;
belongs_to :taggable
&lt;/p&gt;&lt;p&gt;
belongs_to :tag
&lt;/p&gt;&lt;p&gt;
end
&lt;/p&gt;&lt;p&gt;
class Tag
&lt;/p&gt;&lt;p&gt;
include DataMapper::Resource
&lt;/p&gt;&lt;p&gt;
property :id, Integer, :serial =&gt; true
&lt;/p&gt;&lt;p&gt;
has n, :taggings
&lt;/p&gt;&lt;p&gt;
has n, :taggables, :through =&gt; :taggings
&lt;/p&gt;&lt;p&gt;
end
&lt;/p&gt;&lt;p&gt;
taggable = Taggable.new
&lt;/p&gt;&lt;p&gt;
taggable.tags
&lt;/p&gt;&lt;p&gt;
taggable.save
&lt;/p&gt;&lt;p&gt;
Trying to access the remote association and then saving raises this strange error:
&lt;/p&gt;&lt;p&gt;
DataMapper::Associations::ImmutableAssociationError: You can not modify this assocation
&lt;/p&gt;&lt;p&gt;
from /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/associations/one_to_many.rb:247:in `assert_mutable'
&lt;/p&gt;&lt;p&gt;
from /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/associations/one_to_many.rb:199:in `save'
&lt;/p&gt;&lt;p&gt;
from /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/resource.rb:272:in `hookable__save_nan_before_advised'
&lt;/p&gt;&lt;p&gt;
from /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/resource.rb:272:in `each'
&lt;/p&gt;&lt;p&gt;
from /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/resource.rb:272:in `hookable__save_nan_before_advised'
&lt;/p&gt;&lt;p&gt;
from /Library/Ruby/Gems/1.8/gems/extlib-0.9.3/lib/extlib/hook.rb:294:in `save!'
&lt;/p&gt;&lt;p&gt;
from /Library/Ruby/Gems/1.8/gems/extlib-0.9.3/lib/extlib/hook.rb:292:in `catch'
&lt;/p&gt;&lt;p&gt;
from /Library/Ruby/Gems/1.8/gems/extlib-0.9.3/lib/extlib/hook.rb:292:in `save!'
&lt;/p&gt;&lt;p&gt;
from /Library/Ruby/Gems/1.8/gems/dm-validations-0.9.3/lib/dm-validations.rb:44:in `save'
&lt;/p&gt;&lt;p&gt;
from (irb):39
&lt;/p&gt;&lt;/div&gt;</original-body-html>
  <versions type="array">
    <version type="Ticket::Version">
      <assigned-user-id type="integer">3477</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>&lt;pre&gt;&lt;code&gt;
class Taggable
include DataMapper::Resource
property :id, Integer, :serial =&gt; true
has n, :taggings
has n, :tags, :through =&gt; :taggings
end

class Tagging
include DataMapper::Resource
property :id, Integer, :serial =&gt; true
belongs_to :taggable
belongs_to :tag
end

class Tag
include DataMapper::Resource
property :id, Integer, :serial =&gt; true
has n, :taggings
has n, :taggables, :through =&gt; :taggings
end

taggable = Taggable.new
taggable.tags
taggable.save
&lt;/code&gt;&lt;/pre&gt;

Trying to access the remote association and then saving raises this strange error:

&lt;pre&gt;
DataMapper::Associations::ImmutableAssociationError: You can not modify this assocation
	from /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/associations/one_to_many.rb:247:in `assert_mutable'
	from /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/associations/one_to_many.rb:199:in `save'
	from /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/resource.rb:272:in `hookable__save_nan_before_advised'
	from /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/resource.rb:272:in `each'
	from /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/resource.rb:272:in `hookable__save_nan_before_advised'
	from /Library/Ruby/Gems/1.8/gems/extlib-0.9.3/lib/extlib/hook.rb:294:in `save!'
	from /Library/Ruby/Gems/1.8/gems/extlib-0.9.3/lib/extlib/hook.rb:292:in `catch'
	from /Library/Ruby/Gems/1.8/gems/extlib-0.9.3/lib/extlib/hook.rb:292:in `save!'
	from /Library/Ruby/Gems/1.8/gems/dm-validations-0.9.3/lib/dm-validations.rb:44:in `save'
	from (irb):39
&lt;/pre&gt;</body>
      <body-html>&lt;div&gt;&lt;p&gt;
&lt;pre&gt;&lt;code&gt;
&lt;/p&gt;&lt;p&gt;
class Taggable
&lt;/p&gt;&lt;p&gt;
include DataMapper::Resource
&lt;/p&gt;&lt;p&gt;
property :id, Integer, :serial =&gt; true
&lt;/p&gt;&lt;p&gt;
has n, :taggings
&lt;/p&gt;&lt;p&gt;
has n, :tags, :through =&gt; :taggings
&lt;/p&gt;&lt;p&gt;
end
&lt;/p&gt;&lt;p&gt;
class Tagging
&lt;/p&gt;&lt;p&gt;
include DataMapper::Resource
&lt;/p&gt;&lt;p&gt;
property :id, Integer, :serial =&gt; true
&lt;/p&gt;&lt;p&gt;
belongs_to :taggable
&lt;/p&gt;&lt;p&gt;
belongs_to :tag
&lt;/p&gt;&lt;p&gt;
end
&lt;/p&gt;&lt;p&gt;
class Tag
&lt;/p&gt;&lt;p&gt;
include DataMapper::Resource
&lt;/p&gt;&lt;p&gt;
property :id, Integer, :serial =&gt; true
&lt;/p&gt;&lt;p&gt;
has n, :taggings
&lt;/p&gt;&lt;p&gt;
has n, :taggables, :through =&gt; :taggings
&lt;/p&gt;&lt;p&gt;
end
&lt;/p&gt;&lt;p&gt;
taggable = Taggable.new
&lt;/p&gt;&lt;p&gt;
taggable.tags
&lt;/p&gt;&lt;p&gt;
taggable.save
&lt;/p&gt;&lt;p&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/p&gt;&lt;p&gt;
Trying to access the remote association and then saving raises this strange error:
&lt;/p&gt;&lt;p&gt;
&lt;pre&gt;
&lt;/p&gt;&lt;p&gt;
DataMapper::Associations::ImmutableAssociationError: You can not modify this assocation
&lt;/p&gt;&lt;p&gt;
from /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/associations/one_to_many.rb:247:in `assert_mutable'
&lt;/p&gt;&lt;p&gt;
from /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/associations/one_to_many.rb:199:in `save'
&lt;/p&gt;&lt;p&gt;
from /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/resource.rb:272:in `hookable__save_nan_before_advised'
&lt;/p&gt;&lt;p&gt;
from /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/resource.rb:272:in `each'
&lt;/p&gt;&lt;p&gt;
from /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/resource.rb:272:in `hookable__save_nan_before_advised'
&lt;/p&gt;&lt;p&gt;
from /Library/Ruby/Gems/1.8/gems/extlib-0.9.3/lib/extlib/hook.rb:294:in `save!'
&lt;/p&gt;&lt;p&gt;
from /Library/Ruby/Gems/1.8/gems/extlib-0.9.3/lib/extlib/hook.rb:292:in `catch'
&lt;/p&gt;&lt;p&gt;
from /Library/Ruby/Gems/1.8/gems/extlib-0.9.3/lib/extlib/hook.rb:292:in `save!'
&lt;/p&gt;&lt;p&gt;
from /Library/Ruby/Gems/1.8/gems/dm-validations-0.9.3/lib/dm-validations.rb:44:in `save'
&lt;/p&gt;&lt;p&gt;
from (irb):39
&lt;/p&gt;&lt;p&gt;
&lt;/pre&gt;
&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-07-26T18:56:52-05:00</created-at>
      <creator-id type="integer">26603</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">485</number>
      <permalink>has-n-through-does-not-allow-saving-of-model</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">20609</project-id>
      <state>new</state>
      <tag>associations dm-core has_and_belongs_to_many</tag>
      <title>&quot;has n, :through...&quot; does not allow saving of model</title>
      <updated-at type="datetime">2008-07-26T18:56:52-05:00</updated-at>
      <user-id type="integer">26603</user-id>
      <user-name>Bobby Calderwood</user-name>
      <creator-name>Bobby Calderwood</creator-name>
      <assigned-user-name>Sam Smoot</assigned-user-name>
      <url>http://datamapper.lighthouseapp.com/projects/20609/tickets/485</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">3477</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>I just ran into this bug, too.  Looks like the logic in OneToMany#assert_mutable (http://github.com/sam/dm-core/tree/master/lib/dm-core/associations/one_to_many.rb#L247) needs to account for :through associations.</body>
      <body-html>&lt;div&gt;&lt;p&gt;I just ran into this bug, too.  Looks like the logic in OneToMany#assert_mutable (&lt;a href=&quot;http://github.com/sam/dm-core/tree/master/lib/dm-core/associations/one_to_many.rb#L247&quot;&gt;http://github.com/sam/dm-core/tr...&lt;/a&gt;) needs to account for :through associations.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-08-24T14:52:05-05:00</created-at>
      <creator-id type="integer">26603</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">485</number>
      <permalink>has-n-through-does-not-allow-saving-of-model</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">20609</project-id>
      <state>new</state>
      <tag>associations dm-core has_and_belongs_to_many</tag>
      <title>&quot;has n, :through...&quot; does not allow saving of model</title>
      <updated-at type="datetime">2008-08-24T14:52:05-05:00</updated-at>
      <user-id type="integer">29883</user-id>
      <user-name>nicholaides</user-name>
      <creator-name>Bobby Calderwood</creator-name>
      <assigned-user-name>Sam Smoot</assigned-user-name>
      <url>http://datamapper.lighthouseapp.com/projects/20609/tickets/485</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">3477</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>Is anybody looking into this? This is still a problem.

The first error in this script highlights the problem as well:

http://gist.github.com/raw/21256/fcc60e2e3dbff5ecc07f84c9394d1eeda960f464</body>
      <body-html>&lt;div&gt;&lt;p&gt;Is anybody looking into this? This is still a problem.&lt;/p&gt;
&lt;p&gt;The first error in this script highlights the problem as
well:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://gist.github.com/raw/21256/fcc60e2e3dbff5ecc07f84c9394d1eeda960f464&quot;&gt;
http://gist.github.com/raw/21256...&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-11-10T18:38:30-06:00</created-at>
      <creator-id type="integer">26603</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">485</number>
      <permalink>has-n-through-does-not-allow-saving-of-model</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">20609</project-id>
      <state>new</state>
      <tag>associations dm-core has_and_belongs_to_many</tag>
      <title>&quot;has n, :through...&quot; does not allow saving of model</title>
      <updated-at type="datetime">2008-11-10T18:38:31-06:00</updated-at>
      <user-id type="integer">16843</user-id>
      <user-name>Kyle Drake</user-name>
      <creator-name>Bobby Calderwood</creator-name>
      <assigned-user-name>Sam Smoot</assigned-user-name>
      <url>http://datamapper.lighthouseapp.com/projects/20609/tickets/485</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">3477</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>I am curious - why is this not working?</body>
      <body-html>&lt;div&gt;&lt;p&gt;I am curious - why is this not working?&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-11-14T08:04:30-06:00</created-at>
      <creator-id type="integer">26603</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">485</number>
      <permalink>has-n-through-does-not-allow-saving-of-model</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">20609</project-id>
      <state>new</state>
      <tag>associations dm-core has_and_belongs_to_many</tag>
      <title>&quot;has n, :through...&quot; does not allow saving of model</title>
      <updated-at type="datetime">2008-11-14T08:04:33-06:00</updated-at>
      <user-id type="integer">14372</user-id>
      <user-name>Vladimir Lushnikov</user-name>
      <creator-name>Bobby Calderwood</creator-name>
      <assigned-user-name>Sam Smoot</assigned-user-name>
      <url>http://datamapper.lighthouseapp.com/projects/20609/tickets/485</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">3477</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>a workaround is
@@@
class Tag
  include DataMapper::Resource
  property :id, Serial
  has n, :taggings
  has n, :tags, :through =&gt; :taggings, :mutable =&gt; true
end
@@@
adding this :mutable option.

I think the opposite default for the mutable option would be a better choice. see the patch to see where to fix it (or apply the patch)</body>
      <body-html>&lt;div&gt;&lt;p&gt;a workaround is&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
class Tag
  include DataMapper::Resource
  property :id, Serial
  has n, :taggings
  has n, :tags, :through =&amp;gt; :taggings, :mutable =&amp;gt; true
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;adding this :mutable option.&lt;/p&gt;
&lt;p&gt;I think the opposite default for the mutable option would be a
better choice. see the patch to see where to fix it (or apply the
patch)&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-11-17T13:41:50-06:00</created-at>
      <creator-id type="integer">26603</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">485</number>
      <permalink>has-n-through-does-not-allow-saving-of-model</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">20609</project-id>
      <state>new</state>
      <tag>associations dm-core has_and_belongs_to_many</tag>
      <title>&quot;has n, :through...&quot; does not allow saving of model</title>
      <updated-at type="datetime">2008-11-17T13:41:52-06:00</updated-at>
      <user-id type="integer">34710</user-id>
      <user-name>kristian</user-name>
      <creator-name>Bobby Calderwood</creator-name>
      <assigned-user-name>Sam Smoot</assigned-user-name>
      <url>http://datamapper.lighthouseapp.com/projects/20609/tickets/485</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">3477</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>The patch sent has the line:

@mutable = options.delete(:mutable) || true

That will always return true. You should something like:

@mutable = options[:mutable] ? options.delete(:mutable) : true

Regards,
Jos&#233; Valim.</body>
      <body-html>&lt;div&gt;&lt;p&gt;The patch sent has the line:&lt;/p&gt;
&lt;p&gt;@mutable = options.delete(:mutable) || true&lt;/p&gt;
&lt;p&gt;That will always return true. You should something like:&lt;/p&gt;
&lt;p&gt;@mutable = options[:mutable] ? options.delete(:mutable) :
true&lt;/p&gt;
&lt;p&gt;Regards, Jos&amp;eacute; Valim.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-11-22T12:33:24-06:00</created-at>
      <creator-id type="integer">26603</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">485</number>
      <permalink>has-n-through-does-not-allow-saving-of-model</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">20609</project-id>
      <state>new</state>
      <tag>associations dm-core has_and_belongs_to_many</tag>
      <title>&quot;has n, :through...&quot; does not allow saving of model</title>
      <updated-at type="datetime">2008-11-22T12:33:27-06:00</updated-at>
      <user-id type="integer">19965</user-id>
      <user-name>Jos&#233; Valim</user-name>
      <creator-name>Bobby Calderwood</creator-name>
      <assigned-user-name>Sam Smoot</assigned-user-name>
      <url>http://datamapper.lighthouseapp.com/projects/20609/tickets/485</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer" nil="true"></assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>I'm not sure this is an issue.

The through resource may well be some complex item which cannot be created from defaults.  On the other hand, if it can, allowing that to happen is a good thing,</body>
      <body-html>&lt;div&gt;&lt;p&gt;I'm not sure this is an issue.&lt;/p&gt;
&lt;p&gt;The through resource may well be some complex item which cannot
be created from defaults. On the other hand, if it can, allowing
that to happen is a good thing,&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-11-30T09:22:12-06:00</created-at>
      <creator-id type="integer">26603</creator-id>
      <diffable-attributes type="yaml">--- 
:state: new
:assigned_user: 3477
</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">485</number>
      <permalink>has-n-through-does-not-allow-saving-of-model</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">20609</project-id>
      <state>hold</state>
      <tag>associations dm-core has_and_belongs_to_many</tag>
      <title>&quot;has n, :through...&quot; does not allow saving of model</title>
      <updated-at type="datetime">2008-11-30T09:22:13-06:00</updated-at>
      <user-id type="integer">21441</user-id>
      <user-name>Jonathan Stott (namelessjon)</user-name>
      <creator-name>Bobby Calderwood</creator-name>
      <assigned-user-name nil="true"></assigned-user-name>
      <url>http://datamapper.lighthouseapp.com/projects/20609/tickets/485</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer" nil="true"></assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>I can confirm that has n, :through still exhibits this behavior.

However, this is by design until we can work out the cases when the join record can be automatically created vs where it cannot.

If the join record only contains references to both sides of the association, then no problem.  If it contains reference AND properties with default values, also no problem.  However, in the case where it references both sides AND has a property without a default, we'd still need to throw an exception because it will be impossible for DM to fill in the missing information when creating the join record.

We just need to codify this so that :through associations can be modified in certain situations.  This work will be ongoing in the dkubb/dm-core fork over the next couple of months.</body>
      <body-html>&lt;div&gt;&lt;p&gt;I can confirm that has n, :through still exhibits this
behavior.&lt;/p&gt;
&lt;p&gt;However, this is by design until we can work out the cases when
the join record can be automatically created vs where it
cannot.&lt;/p&gt;
&lt;p&gt;If the join record only contains references to both sides of the
association, then no problem. If it contains reference AND
properties with default values, also no problem. However, in the
case where it references both sides AND has a property without a
default, we'd still need to throw an exception because it will be
impossible for DM to fill in the missing information when creating
the join record.&lt;/p&gt;
&lt;p&gt;We just need to codify this so that :through associations can be
modified in certain situations. This work will be ongoing in the
dkubb/dm-core fork over the next couple of months.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-12-04T03:14:39-06:00</created-at>
      <creator-id type="integer">26603</creator-id>
      <diffable-attributes type="yaml">--- 
:state: hold
</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">485</number>
      <permalink>has-n-through-does-not-allow-saving-of-model</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">20609</project-id>
      <state>confirmed</state>
      <tag>associations dm-core has_and_belongs_to_many</tag>
      <title>&quot;has n, :through...&quot; does not allow saving of model</title>
      <updated-at type="datetime">2008-12-04T03:14:42-06:00</updated-at>
      <user-id type="integer">5609</user-id>
      <user-name>Dan Kubb (dkubb)</user-name>
      <creator-name>Bobby Calderwood</creator-name>
      <assigned-user-name nil="true"></assigned-user-name>
      <url>http://datamapper.lighthouseapp.com/projects/20609/tickets/485</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">5609</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body></body>
      <body-html></body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-01-07T16:26:06-06:00</created-at>
      <creator-id type="integer">26603</creator-id>
      <diffable-attributes type="yaml">--- 
:assigned_user: 
</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">485</number>
      <permalink>has-n-through-does-not-allow-saving-of-model</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">20609</project-id>
      <state>confirmed</state>
      <tag>associations dm-core has_and_belongs_to_many</tag>
      <title>&quot;has n, :through...&quot; does not allow saving of model</title>
      <updated-at type="datetime">2009-01-07T16:26:09-06:00</updated-at>
      <user-id type="integer">5609</user-id>
      <user-name>Dan Kubb (dkubb)</user-name>
      <creator-name>Bobby Calderwood</creator-name>
      <assigned-user-name>Dan Kubb (dkubb)</assigned-user-name>
      <url>http://datamapper.lighthouseapp.com/projects/20609/tickets/485</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">5609</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body></body>
      <body-html></body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-01-07T16:33:31-06:00</created-at>
      <creator-id type="integer">26603</creator-id>
      <diffable-attributes type="yaml">--- 
:state: confirmed
</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">485</number>
      <permalink>has-n-through-does-not-allow-saving-of-model</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">20609</project-id>
      <state>accepted</state>
      <tag>associations dm-core has_and_belongs_to_many</tag>
      <title>&quot;has n, :through...&quot; does not allow saving of model</title>
      <updated-at type="datetime">2009-01-07T16:33:32-06:00</updated-at>
      <user-id type="integer">5609</user-id>
      <user-name>Dan Kubb (dkubb)</user-name>
      <creator-name>Bobby Calderwood</creator-name>
      <assigned-user-name>Dan Kubb (dkubb)</assigned-user-name>
      <url>http://datamapper.lighthouseapp.com/projects/20609/tickets/485</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">5609</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>@Jos&#233; Valim

This:

@@@ruby
@mutable = options[:mutable] ? options.delete(:mutable) : true
@@@

will also return true ALWAYS. options[:mutable] can return &quot;nil&quot; or &quot;false&quot;, if it will return false condition will not be met and will choose &quot;true&quot;.

Better would be:

@@@ruby
@mutable = options.key?(:mutable) ? options.delete(:mutable) : true
@@@</body>
      <body-html>&lt;div&gt;&lt;p&gt;@Jos&amp;eacute; Valim&lt;/p&gt;
&lt;p&gt;This:&lt;/p&gt;
&lt;p&gt;@@@ruby @mutable = options[:mutable] ? options.delete(:mutable)
: true&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;

will also return true ALWAYS. options[:mutable] can return &amp;quot;nil&amp;quot; or &amp;quot;false&amp;quot;, if it will return false condition will not be met and will choose &amp;quot;true&amp;quot;.

Better would be:

@@@ruby
@mutable = options.key?(:mutable) ? options.delete(:mutable) : true
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-01-08T05:22:14-06:00</created-at>
      <creator-id type="integer">26603</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">485</number>
      <permalink>has-n-through-does-not-allow-saving-of-model</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">20609</project-id>
      <state>accepted</state>
      <tag>associations dm-core has_and_belongs_to_many</tag>
      <title>&quot;has n, :through...&quot; does not allow saving of model</title>
      <updated-at type="datetime">2009-01-08T05:22:15-06:00</updated-at>
      <user-id type="integer">34912</user-id>
      <user-name>Marcin Kulik</user-name>
      <creator-name>Bobby Calderwood</creator-name>
      <assigned-user-name>Dan Kubb (dkubb)</assigned-user-name>
      <url>http://datamapper.lighthouseapp.com/projects/20609/tickets/485</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">5609</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>I can confirm this issue is resolved in dm-core/next.  Attached is a script to demonstrate the fix.</body>
      <body-html>&lt;div&gt;&lt;p&gt;I can confirm this issue is resolved in dm-core/next. Attached
is a script to demonstrate the fix.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-05-28T03:27:16-05:00</created-at>
      <creator-id type="integer">26603</creator-id>
      <diffable-attributes type="yaml">--- 
:state: accepted
</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">485</number>
      <permalink>has-n-through-does-not-allow-saving-of-model</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">20609</project-id>
      <state>resolved</state>
      <tag>associations dm-core has_and_belongs_to_many</tag>
      <title>&quot;has n, :through...&quot; does not allow saving of model</title>
      <updated-at type="datetime">2009-05-28T03:27:19-05:00</updated-at>
      <user-id type="integer">5609</user-id>
      <user-name>Dan Kubb (dkubb)</user-name>
      <creator-name>Bobby Calderwood</creator-name>
      <assigned-user-name>Dan Kubb (dkubb)</assigned-user-name>
      <url>http://datamapper.lighthouseapp.com/projects/20609/tickets/485</url>
    </version>
  </versions>
  <attachments type="array">
    <attachment type="Attachment">
      <code>c9623af7e071818474b045a3eaae8e904d830f02</code>
      <content-type>application/octet-stream</content-type>
      <created-at type="datetime">2008-11-17T13:41:50-06:00</created-at>
      <filename>patch</filename>
      <height type="integer" nil="true"></height>
      <id type="integer">62878</id>
      <size type="integer">575</size>
      <uploader-id type="integer">34710</uploader-id>
      <width type="integer" nil="true"></width>
      <url>http://datamapper.lighthouseapp.com/attachments/62878/patch</url>
    </attachment>
    <attachment type="Attachment">
      <code>f5a727f7bf32d64f1acf65dcaa6098e27acb8144</code>
      <content-type>application/octet-stream</content-type>
      <created-at type="datetime">2009-05-28T03:27:16-05:00</created-at>
      <filename>ticket-485.rb</filename>
      <height type="integer" nil="true"></height>
      <id type="integer">127051</id>
      <size type="integer">613</size>
      <uploader-id type="integer">5609</uploader-id>
      <width type="integer" nil="true"></width>
      <url>http://datamapper.lighthouseapp.com/attachments/127051/ticket-485.rb</url>
    </attachment>
  </attachments>
</ticket>
