June 2024
Intermediate to advanced
456 pages
11h 34m
English
In this section, you’ll work with the Ruby gem Scenic[145] to create database views.
Scenic works like Active Record. Similar to how create_table generates a SQL CREATE TABLE DDL statement, Scenic adds a create_view helper to generate DDL for creating database views.
The Scenic generator creates two files. The first is a plain text .sql file where you place the SQL query definition of your view. The second file is an Active Record migration that has the .add_view method which adds the view based on the .sql file SQL definition.
Scenic was added to Rideshare, along with a view to search for drivers. Open psql and run \dv to describe the views. You should see a view named search_results.
Using Scenic, ...
Read now
Unlock full access