
has n, :through, :class_name unexpected failure with :links
Reported by Max Aller | June 14th, 2008 @ 01:13 PM
I have a Account, a join table, and a Project, and I want to be able to access projects associated with an account by accessing a .created_projects on an Account instance.
In my Account class, I have
has n, :projects, :through => :join_account_projects
which works fine, but isn't quite what I want. I try this
has n, :created_projects, :through => :join_account_projects, :class_name => 'Project'
and I get
ArgumentError: +options[:links]+ cannot be empty
from /usr/lib/ruby/gems/1.8/gems/dm-core-0.9.2/lib/dm-core/query.rb:362:in `assert_valid_options'
Not sure what's going on, but this doesn't seem like it should be the case.
Source: http://www.pastie.org/215085
Full stack trace: http://www.pastie.org/215086
For the record, Project.first.creator doesn't work, giving the same error.
Comments and changes to this ticket
-
Dan Kubb (dkubb) June 16th, 2008 @ 02:55 AM
- State changed from new to resolved
This issue should be resolved by the following commit:
http://github.com/sam/dm-core/co...
I am marking this ticket as resolved for now. If it is still a problem for you please add a comment here and I'll re-open this ticket.
-
Max Aller June 16th, 2008 @ 12:56 PM
Unfortunately that commit didn't fix it. I think the stack trace is the same, but line numbers are slightly different: http://www.pastie.org/215956
-
Dan Kubb (dkubb) June 17th, 2008 @ 06:40 PM
- State changed from resolved to open
- Milestone cleared.
Max, can you attach a failing spec? I haven't been able to reproduce this on my end.
-
Max Aller June 23rd, 2008 @ 07:33 PM
Upon the discovery of the :remote_relationship_name attribute, this ticket is no longer applicable. Which means, instead of the two lines of code in my original ticket, I have
has n, :created_projects, :through => :join_account_projects, :class_name => 'Project', :remote_relationship_name => :project
and that works fine. It'd be nice if it wasn't necessary to specify :class_name, but that's much more minor.
-> Close ticket please!
-
Dan Kubb (dkubb) June 23rd, 2008 @ 08:18 PM
- Assigned user changed from Sam Smoot to Bernerd Schaefer
Max, I think its probably a bug that you have to specify the :class_name here, so I'll leave this open for now.
I'm assigning this to Bernerd who did alot of the work on habtm and has n, :through, he should know how to resolve it more quickly than I could,
-
Dan Kubb (dkubb) January 8th, 2009 @ 04:37 AM
- Tag set to associations, bug
- State changed from open to accepted
- Assigned user changed from Bernerd Schaefer to Dan Kubb (dkubb)
-
Justin Smestad February 23rd, 2009 @ 04:21 PM
Tried with the above example and did not happen for me using dm-next branch. I used the following source:
class Account include DataMapper::Resource
has n, :join_account_projects, :child_key => [:account_id] has n, :created_projects, :through => :join_account_projects, :class_name => 'Project' #has n, :projects, :through => :join_account_projects end
class JoinAccountProject include DataMapper::Resource property :id, Integer, :serial => true property :account_id, Integer property :project_id, Integer property :role, Integer
belongs_to :account belongs_to :project end
class Project include DataMapper::Resource property :id, Integer, :serial => true property :title, String property :blurb, String property :mission, String property :description, Text property :joinable, Integer property :state, Integer
has n, :join_account_projects, :child_key => [:project_id] has 1, :creator, :through => :join_account_projects, :class_name => 'Account' end
-
Dan Kubb (dkubb) June 7th, 2009 @ 03:39 AM
- State changed from accepted to resolved
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »