Hi all — I’m currently experimenting with the “Entry” pattern elucidated with the introduction of delegated_type
in Rails 6.1. Seems like a very powerful pattern to build a project upon, which I’m excited about.
At the risk of asking naive questions to a bunch of experts… how should controllers look for the various entryable types’ controllers (e.g. Messages and Comments from the official examples)?
I’ve searched up all the public repos using delegated_type
on GitHub, but it seems like most of them don’t have controllers for those resources.
In my tests, the create
action in a scaffolded Messages controller won’t Create an associated Entry. I can see the server SELECT
ing on the Entry table for the appropriate entryable_id
+ entryable_type
, but it doesn’t exist and it doesn’t attempt to create one.
Is that expected?
The suggestion from the docs is to use:
Entry.create! entryable: Comment.new(content: "Hello!"), creator: Current.user
Is that necessary for Controllers — and, if so, should that be included as a concern so that each Entryable type’s controller can just include the Entry creation behaviour?
Thanks for reading. Any advice welcome