You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've already posted this on Stackoverflow for more help, but I also post it here.
So I have models like this:
folder, up_file has 1 chat_room
chat_room belongs to crmable with polymorphic: true (so 1 chat_room may belongs to folder or 1 up_file)
chat_room has many comments
comment belongs to chat_room and user (who posted the comment)
I've defined all relationship like this:
class Folder < ApplicationRecord
has_one :chat_room, as: :crmable, dependent: :destroy
end
class UpFile < ApplicationRecord
has_one :chat_room, as: :crmable, dependent: :destroy
end
class ChatRoom < ApplicationRecord
belongs_to :crmable, polymorphic: true
has_many :comments, dependent: :destroy
has_many :users, through: :comments
end
class Comment < ApplicationRecord
belongs_to :chat_room
belongs_to :user
end
I've follow their tutorial here but my associations not rendered.
class FolderSerializer < ActiveModel::Serializer
attributes :id, :name, :ancestry, :creator_name #... my other attributes
has_one :chat_room, include: [ :id, comments: :user ]
# ^ I tried to serialize folder's chat_room with all it comments, along with these comments' users.
end
All I got is this - chat_room association not serialized?
The text was updated successfully, but these errors were encountered:
I've already posted this on Stackoverflow for more help, but I also post it here.
So I have models like this:
folder
,up_file
has 1chat_room
chat_room
belongs tocrmable
with polymorphic: true (so 1chat_room
may belongs tofolder
or 1up_file
)chat_room
has manycomments
comment
belongs tochat_room
anduser
(who posted the comment)I've defined all relationship like this:
I've follow their tutorial here but my associations not rendered.
All I got is this -
chat_room
association not serialized?The text was updated successfully, but these errors were encountered: