remote_name option missing in has_many through associations
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
- 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.