mmd-osm left a comment (openstreetmap/openstreetmap-website#6326)

I'm a bit lost how the normalisation is supposed to work - without changing 
anything on the db schema. I tried to use   `has_many :element_tags, :as => 
:relation_tags`, but PostgreSQL was complaining about some unknown 
columns/types.

In the meantime, the previous code is now a bit more generic, and derives 
associations from class names. I think that's not too bad.

```ruby
  def prefetch_member_tags(feature)
    members = feature.relation_members.filter_map(&:member)

    members.group_by(&:class).each do |klass, records|
      association = :"#{klass.name.downcase}_tags"

      ActiveRecord::Associations::Preloader.new(
        :records => records,
        :associations => association
      ).call
    end
  end
```

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6326#issuecomment-3198171654
You are receiving this because you are subscribed to this thread.

Message ID: 
<openstreetmap/openstreetmap-website/pull/6326/c3198171...@github.com>
_______________________________________________
rails-dev mailing list
rails-dev@openstreetmap.org
https://lists.openstreetmap.org/listinfo/rails-dev

Reply via email to