Commit
c9c81cfa67b812a4624765f22b28b6c1b88a2aa5
Exists in
staging
and in
39 other branches
all_pending_tasks_api, api-articles-period, api_roles, caching-rails4, captcha_serpro_plugin, comments_permissions, elasticsearch, elasticsearch_api, elasticsearch_categories, elasticsearch_filter, elasticsearch_sort, elasticsearch_to_merge, elasticsearch_view, environment-exposes-api, export-comment-api, export-comment-paragraph, export_data, external_followers, federation-webfinger, federation_followers, federation_followers_backend, federation_oauth_provider, federation_webfinger, fix_notification_email, fix_string_downcase_and_upcase, follower_permition, json_cookie_serializer, login-captcha, master, master_profile_followers, oauth_external_login, oauth_login, private-scraps, private-scraps-rebase, production, production-vendorized, profile_api_improvements, user_mention, webfinger_server
rails4: apply associations extensions to child classes
1
| require 'noosfero/core_ext/string' |
1
| require 'noosfero/core_ext/string' |
2
| require 'noosfero/core_ext/integer' |
2
| require 'noosfero/core_ext/integer' |
3
| require 'noosfero/core_ext/active_record' |
3
| require 'noosfero/core_ext/active_record' |
| |
4
| +require 'noosfero/core_ext/active_record/reflection' |
| |
5
| + |
| @@ -0,0 +1,20 @@ |
| @@ -0,0 +1,20 @@ |
| |
1
| + |
| |
2
| +# on STI classes tike Article and Profile, plugins' extensions |
| |
3
| +# on associations should be reflected on descendants |
| |
4
| +module ActiveRecord |
| |
5
| + module Reflection |
| |
6
| + |
| |
7
| + class << self |
| |
8
| + |
| |
9
| + def add_reflection_with_descendants(ar, name, reflection) |
| |
10
| + self.add_reflection_without_descendants ar, name, reflection |
| |
11
| + ar.descendants.each do |k| |
| |
12
| + k._reflections.merge!(name.to_s => reflection) |
| |
13
| + end if ar.base_class == ar |
| |
14
| + end |
| |
15
| + |
| |
16
| + alias_method_chain :add_reflection, :descendants |
| |
17
| + |
| |
18
| + end |
| |
19
| + end |
| |
20
| +end |