-
Notifications
You must be signed in to change notification settings - Fork 442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
has_many_through and is_valid fixes #303
has_many_through and is_valid fixes #303
Conversation
…o table instead of one. Added through_key in configuration of HasMany
… right keys. Test Done.
Terrific work @lazel! I'm glad to see you didn't give up after all...! Look forward to reviewing these changes and merging into master. |
Thank you @al-the-x :) Has many through is also better than the previous request of merging, this is "smarter" :) However, digging in code, I think eager load of this kind of relationship doesn't work properly: I'll do more research when I've some other free time! |
Looks like the build is failing because the scema files don't include one of your tables. Could you include that schema in your PR as well? |
Yes, I've already updated it in my fork, but I'm still new in using github and when I've requested the merging, instead of master, I set a particular commit and I haven't found a way to change/update it ^^" EDIT: I'm glad I was wrong: eager load work properly :) |
Assigning to me to coach @iazel through sorting his Github rebasing issues... |
are there any news concerning this merge requests? |
Working on this: php-activerecord/Iazel-hmt-and-is_valid-fixes |
Closing in favor of #464 |
has_many_through rely on other relationship to get the correct keys, but this means that every relationship of this kind must reside both in model A and model B.
An example from foo_helper:
As you can see, the foreign key in active_services is "serv_id". Then User model will use that key for joins.
Plus, is possible use this kind of relationship with "joins" option:
Model's
is_valid
andis_invalid
have been fixed. Now they do not revalidate model at each call, but only when validation is required (ex: first time, or when an attribute has been modified). This methods accept a parameter that iftrue
will run validations; useful only when a virtual attribute change and is used in some validations (because that can't be tracked).Test included, for more information see them: HasManyThrough - Validations