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
class TodoList < ActiveRecord::Base
belongs_to :user
has_many :todo_items
end
And I use acts_as_list to track priority of TodoItem´s.
class TodoItem < ActiveRecord::Base
acts_as_list scope: :todo_list, column: :priority
end
I want to have different kinds of TodoItems, so I'll use STI
class PersonalItem < TodoItem
end
class SharedItem < TodoItem
end
I'll also define respective representers
class TodoItemRepresenter < Representable::Decorator
# define shared properties here
end
# inherit TodoItemRepresenter for subclass representers
class PersonalItemRepresenter < TodoItemRepresenter
# properties specific for PersonalItems
end
class SharedItemRepresenter < TodoItemRepresenter
# properties specific for SharedItem
end
Now the question is: is there a built in way to dynamically choose the correct representer based on the actual class? I'd prefer to call something similar to .for_collection.new(user.todo_items) instead of doing something like
This is a question
Hi!
Lets say that I have
And I use acts_as_list to track priority of
TodoItem
´s.I want to have different kinds of
TodoItem
s, so I'll use STII'll also define respective representers
Now the question is: is there a built in way to dynamically choose the correct representer based on the actual class? I'd prefer to call something similar to
.for_collection.new(user.todo_items)
instead of doing something likeThe text was updated successfully, but these errors were encountered: