
remote_name option missing in has_many through associations
Reported by Deleted User | June 27th, 2009 @ 01:09 AM | in 0.10.0
As per the title, this option (which was present in v0.9.x) is missing in v0.10.0 which means datamapper is not able to find the target in the through model if it has a different name than has been used in the through declaration. Not a very clear explanation probably - here's some code to illustrate expected behavior:
class User
include DataMapper::Resource
property :id, Serial
end
class Paper
include DataMapper::Resource
property :id, Serial
has n, :author_joins
has n, :authors, User, :through => :author_joins,
:remote_name => :user,
:child_key => [:paper_id]
end
class AuthorJoin
include DataMapper::Resource
property :id, Serial
property :user_id, Integer
property :paper_id, Integer
belongs_to :user
belongs_to :paper
end
user = User.create!
paper = Paper.create!
paper.authors << user # => NameError: Cannot find target relationship authors or author in AuthorJoin within the :default repository
This has the potential to break existing code when upgrading.
I've added a short script which can be run to check if the remote_name option is supported (not that it's a full spec to check behavior fully).
Comments and changes to this ticket
-
Dan Kubb (dkubb) June 27th, 2009 @ 04:04 AM
- Assigned user set to Dan Kubb (dkubb)
- State changed from new to accepted
-
Dan Kubb (dkubb) July 8th, 2009 @ 05:44 PM
- State changed from accepted to resolved
This should now be fixed in edge.
I added a new parameter named "via" that does the same as remote_name did. The option remote_name will also work for a short time, after which it will start to warn and eventually be removed.
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 »