Skip to content
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

Rails 5.0/5.1 compatibility: Define through association before has many through #18080

Commits on Oct 10, 2018

  1. Remove duplicate host_storages association

    According to 85c0224, we want the
    cascading delete to avoid orphaned resources, so we'll remove the one
    that doesn't explicitly say dependent => destroy.
    
    Rails 5.1+ complains about has_many through associations if the through
    association is not yet defined, and in this case, the second
    host_storages association occurs after the through association, so rails
    yells:
    
    ```
         ActiveRecord::HasManyThroughOrderError:
                Cannot have a has_many :through association 'Storage#hosts'
                which goes through 'Storage#host_storages' before the
                through association is defined.
    ```
    
    Extracted from ManageIQ#18076
    jrafanie committed Oct 10, 2018
    Configuration menu
    Copy the full SHA
    6ce9a5c View commit details
    Browse the repository at this point in the history
  2. Define the through association before using it

    Rails 5.1+ complains about has_many through associations if the through
    association is not yet defined.
    
    Extracted from ManageIQ#18076
    jrafanie committed Oct 10, 2018
    Configuration menu
    Copy the full SHA
    6423d74 View commit details
    Browse the repository at this point in the history