
has n, :through micro issue
Reported by comboy | November 11th, 2008 @ 04:16 AM
When somebody defines a has n, :through association and he doesn't define has many relation to the :through model, he got some strange errer about calling method name on nil object which may be confusing.
Maybe it's a good idea to let this bad coder know what may be wrong. It's probably not even worth creating a patch but something like
if options[:through] && !relationships.keys.include?(options[:through])
raise ArgumentError, "Relation '#{options[:through]}' not found.", caller
end
in associations.rb in method "has" may do the job.
Comments and changes to this ticket
-
comboy November 11th, 2008 @ 04:26 AM
- Assigned user cleared.
-
comboy November 11th, 2008 @ 04:28 AM
- Assigned user set to Dan Kubb (dkubb)
changed assignee to Dan Kubb, we were talking about this issue on irc
-
Dan Kubb (dkubb) November 30th, 2008 @ 12:30 PM
- State changed from new to open
This sounds like a reasonable case to throw an exception. It would happen at Model compile time, which is good since we would only have to check this once.
-
Dan Kubb (dkubb) December 4th, 2008 @ 03:41 AM
- State changed from open to accepted
-
Dan Kubb (dkubb) January 4th, 2009 @ 03:02 AM
- State changed from accepted to resolved
In dkubb/dm-core the relationship will now throw an exception if you try to use a :through relationship that has not been previously defined. Marking this as 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 »