Title: Automatically create inverse relationship as needed · Issue #89 · hyperstack-org/hyperstack · GitHub
Open Graph Title: Automatically create inverse relationship as needed · Issue #89 · hyperstack-org/hyperstack
X Title: Automatically create inverse relationship as needed · Issue #89 · hyperstack-org/hyperstack
Description: currently hyper-model requires that for the both sides of the belongs_to and has_many relationships are explicitly declared. Seems like the following patch fixes that: module ActiveRecord module Associations class AssociationReflection d...
Open Graph Description: currently hyper-model requires that for the both sides of the belongs_to and has_many relationships are explicitly declared. Seems like the following patch fixes that: module ActiveRecord module As...
X Description: currently hyper-model requires that for the both sides of the belongs_to and has_many relationships are explicitly declared. Seems like the following patch fixes that: module ActiveRecord module As...
Opengraph URL: https://github.com/hyperstack-org/hyperstack/issues/89
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Automatically create inverse relationship as needed","articleBody":"currently hyper-model requires that for the both sides of the belongs_to and has_many relationships are explicitly declared.\r\n\r\nSeems like the following patch fixes that:\r\n\r\n```ruby\r\nmodule ActiveRecord\r\n module Associations\r\n class AssociationReflection\r\n def find_inverse\r\n klass.reflect_on_all_associations.each do |association|\r\n next if association.association_foreign_key != @association_foreign_key\r\n next if association.klass != @owner_class\r\n next if association.attribute == attribute\r\n return association if klass == association.owner_class\r\n end\r\n if macro == :belongs_to\r\n Hyperstack::Component::IsomorphicHelpers.log \"**** warning dynamically adding relationship: #{klass}.has_many :#{@owner_class.name.underscore.pluralize}, foreign_key: #{@association_foreign_key}\", :warning\r\n klass.has_many @owner_class.underscore.pluralize, foreign_key: @association_foreign_key\r\n else\r\n Hyperstack::Component::IsomorphicHelpers.log \"**** warning dynamically adding relationship: #{klass}.belongs_to :#{@owner_class.name.underscore}, foreign_key: #{@association_foreign_key}\", :warning\r\n klass.belongs_to @owner_class.underscore, foreign_key: @association_foreign_key\r\n end\r\n # raise \"Association #{@owner_class}.#{attribute} \"\\\r\n # \"(foreign_key: #{@association_foreign_key}) \"\\\r\n # \"has no inverse in #{@klass_name}\"\r\n end\r\n end\r\n end\r\nend","author":{"url":"https://github.com/catmando","@type":"Person","name":"catmando"},"datePublished":"2018-12-11T19:33:26.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/89/hyperstack/issues/89"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b40d54fb-0b60-6ef1-df94-6f2b2647cabf |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E038:8CF75:2B0C:31F8:6991D669 |
| html-safe-nonce | 272c639e41ba4695216414755648d12fd8d809322585c641e18dda3fd90a78d4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMDM4OjhDRjc1OjJCMEM6MzFGODo2OTkxRDY2OSIsInZpc2l0b3JfaWQiOiI1NDYwMjg0MDA5Mjc0NzkxNTMwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 21a811c629de21e581943bf400d7ac753e703c72217dd40d4e4c99edb2566295 |
| hovercard-subject-tag | issue:389919792 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/hyperstack-org/hyperstack/89/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e064539d33530e725bf177cc24412654816e7d7d057cf2f864c02db96b515e67/hyperstack-org/hyperstack/issues/89 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e064539d33530e725bf177cc24412654816e7d7d057cf2f864c02db96b515e67/hyperstack-org/hyperstack/issues/89 |
| og:image:alt | currently hyper-model requires that for the both sides of the belongs_to and has_many relationships are explicitly declared. Seems like the following patch fixes that: module ActiveRecord module As... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | catmando |
| hostname | github.com |
| expected-hostname | github.com |
| None | 42c603b9d642c4a9065a51770f75e5e27132fef0e858607f5c9cb7e422831a7b |
| turbo-cache-control | no-preview |
| go-import | github.com/hyperstack-org/hyperstack git https://github.com/hyperstack-org/hyperstack.git |
| octolytics-dimension-user_id | 34562730 |
| octolytics-dimension-user_login | hyperstack-org |
| octolytics-dimension-repository_id | 145879576 |
| octolytics-dimension-repository_nwo | hyperstack-org/hyperstack |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 145879576 |
| octolytics-dimension-repository_network_root_nwo | hyperstack-org/hyperstack |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 848bc6032dcc93a9a7301dcc3f379a72ba13b96e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width