Topic: Switching table to STI breaks polymorphic magic...
I tried switching a table to a STI table by adding 'type' and changing the name of the table/class... Then adding the inherited class, now all of a sudden the polymorphic relationship fails to work. Here's the relevant code:
class Topic < ActiveRecord::Base
has_many :comments, :as => :commentables
class Tip < Topic
class Comment < ActiveRecord::Base
belongs_to :commentables, :polymorphic => true
class TopicsController < ApplicationController
@topic = Topic.find(params[:id])
@topic = Topic.random
@comments = Topic.find(@topic.id).comments
Now, when I try to access @comments it's always empty.
I've tried every combination of has_many :comments, :as => :commentables
in Topic & Tip to no avail. As well as moving the "show" code into
class TipsController < TopicsController