Adding Polymorphic Comments to Posts in Ruby on Rails
If a blog post has no comments, was it ever posted? Comments are a common thing to have within any application. In this episode, I'll be adding the comments model and the list controller, as well as building out stubs for the upcoming episode dealing with the rest of the CRUD actions (create, update, delete) for comments. I'll discuss polymorphism within the model and how Rails uses it. We'll add a counter cache to keep track of the number of comments as well.
š¤Æ Support
ā±ļø Timestamps:
š Newsletter:
šŖElsewhere:
šConcepts:
šResources:
š¬ Subscribe!
My name is David W Parker and Iām creating and publishing videos on ProgrammingTIL to help teach anyone and everyone who wants to code. Iām a huge fan of Ruby on Rails, Svelte, TailwindCSS, and WebGL. Iāve used React a lot in the past, as well as some Vue and AngularJS. Iāve done some professional Python and Django. I like to create real applications and my tutorials will walk you through how to build something real from beginning-to-end.
š¤Æ Support
- https://www.patreon.com/davidwparker
- https://www.buymeacoffee.com/davidwparker
ā±ļø Timestamps:
- 00:00 - Introduction
- 00:35 - code coverage results
- 01:00 - comments migration - what is polymorphism?
- 05:00 - comment model
- 06:00 - comment association, validations, logic
- 09:30 - commentable concern
- 10:40 - other changes
- 11:30 - comments controller, policy
- 13:35 - tests
š Newsletter:
- https://www.programmingtil.com/
šŖElsewhere:
- Twitter: https://twitter.com/davidwparker
- Twitter: https://twitter.com/programmingtil
- GitHub: https://github.com/davidwparker
šConcepts:
- Comments
- Polymorphism
- Counter Cache
šResources:
- https://github.com/davidwparker/programmingtil-rails/tree/ep20
š¬ Subscribe!
- http://bit.ly/subdavidwparker
My name is David W Parker and Iām creating and publishing videos on ProgrammingTIL to help teach anyone and everyone who wants to code. Iām a huge fan of Ruby on Rails, Svelte, TailwindCSS, and WebGL. Iāve used React a lot in the past, as well as some Vue and AngularJS. Iāve done some professional Python and Django. I like to create real applications and my tutorials will walk you through how to build something real from beginning-to-end.
ruby #rails #rubyonrails
Ā© programmingtil.com