How to Create Database Views using the Scenic Gem

Опубликовано: 14 Июль 2026
на канале: Mike Rogers
1,878
56

In this tutorial we use the Scenic gem to create a Postgres Database View to view the contents of multiple tables at the same time.

Then I make it awesome & test it with RSpec.

Sources

➡ https://github.com/scenic-views/scenic
➡ https://github.com/MikeRogers0-YouTub...

Chapters

0:00 - What are we going to do
1:41 - Adding Scenic Gem and Database View
4:20 - Accessing our Database view like a normal Rails Model
6:22 - Using a polymorphic relationship to load the original object
11:16 - Adding a primary key to our Database View
14:46 - Testing our view with RSpec
19:06 - Why make models read only
20:36 - Adding created_at & updated_at fields

Follow Me Online

➡ Blog: https://mikerogers.io/
➡ Twitter:   / mikerogers0  
➡ GitHub: https://github.com/mikerogers0
➡ YouTube:    / mikerogers0  
➡ BuyMeACoffee: https://www.buymeacoffee.com/MikeRogers0
➡ Dev.to: https://dev.to/mikerogers0

#RubyOnRails #AwesomeRubyGems #Postgres