Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Automatically guess the inverse associations for STI #23425
ActiveRecord associations automatically guess the inverse associations.
It'd be awesome to get this merged sometime soon. This is the exact behavior I would've expected when interacting with a child record. Instead, for a setup like this:
class Challenge < ApplicationRecord has_many :questions end class Question < ApplicationRecord belongs_to :challenge end class MultipleChoiceQuestion < Question # where `type` == "MultipleChoiceQuestion" end
challenge = Challenge.new MultipleChoiceQuestion.create(challenge: challange)
would give me:
It seems to know that it's an association, but not really...