Ok, I'm still having some problems with this. :mutable => true
certainly solves the original problem, but when @subscription.users
<< @user executes, I'm not seeing any evidence that any join model
object is being saved.
Has anyone else been successful in using has n, :though ?
When I look at the integration spec, association_through_spec.rb, I
see that the examples all involve _explicitly_ creating the join
model:
---
crappy = Tagging.new
post.taggings << crappy
post.save
crap = Tag.create(:title => "crap")
crap.taggings << crappy
crap.save
---
Is this what you have to do in datamapper?? This is definitely not
required in activerecord.
Mark.
On Nov 18, 7:15 am, MarkMT <[EMAIL PROTECTED]> wrote:
> Thanks Kristian. I'm glad there's a workaround. Pretty significant
> issue imo.
>
> Mark.
>
> On Nov 18, 6:28 am, kristian <[EMAIL PROTECTED]> wrote:
>
> > a workaround for this bug is to add :mutable => true as option, i.e.
>
> > has n, :users, :through => :profiles, :mutable => true
>
> > see also my comment
> > herehttp://wm.lighthouseapp.com/projects/4819/tickets/485-has-n-through-d...
>
> > with regards
> > Kristian
>
> > On Nov 17, 7:27 pm, MarkMT <[EMAIL PROTECTED]> wrote:
>
> > > I'm having some difficulty with associations in datamapper - hopefully
> > > someone can show me where my misunderstanding lies...
>
> > > I have two models related by a many to many association via a join
> > > model.
>
> > > ---
> > > class Subscription
>
> > > include DataMapper::Resource
>
> > > property :id, Serial
>
> > > has n, :profiles
> > > has n, :users, :through => :profiles
> > > ---
> > > class User
>
> > > include DataMapper::Resource
>
> > > property :id, Serial
>
> > > has n, :profiles
> > > has n, :subscriptions, :through => :profiles
> > > ---
> > > class Profile
>
> > > include DataMapper::Resource
>
> > > property :subscription_id, Integer, :key => true
> > > property :user_id, Integer, :key => true
>
> > > belongs_to :subscription
> > > belongs_to :user
> > > ---
>
> > > Then in the controller I attempt to instantiate a subscription and
> > > user and associate them...
>
> > > ---
> > > def some_action
> > > @subscription = Subscription.create
> > > @user = User.create
> > > @subscription.users << @user
> > > end
> > > ---
>
> > > When I point my browser at this action, I get the following -
>
> > > Immutable Association Error 500
> > > You can not modify this association
>
> > > I've tried the same association operation with ActiveRecord in Rails
> > > and it works fine there. Evidently there's something different about
> > > datamapper that I don't understand.
>
> > > Any suggestions would be much appreciated.
>
> > > Mark.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---