gene c13,629 Points
How does the server know about the /posts extension?
we didnt create the posts page or type anything into the command line to generate the post page.
Jeff MudayTreehouse Moderator 23,731 Points
RoR has a lot of cool "magic" built-in. When Jay created the "post" Model, he used the command (see below)
The command produces the extensive scaffold code (shown below)
It created all the MVC (Model View Controller) code which makes it possible to do CRUD (Create Read Update Delete) on the model through the web framework.
Check out this video where he generates the scaffold.
After you complete the scaffold, you have to "migrate" the database before it will work (see below)
treehouse:~/workspace/blog$ bin/rails db:migrate RAILS_ENV=development == 20191216195338 CreatePosts: migrating ====================================== -- create_table(:posts) -> 0.0209s == 20191216195338 CreatePosts: migrated (0.0210s) =============================
And then, finally, run the server:
treehouse:~/workspace/blog$ bin/rails server -b 0.0.0.0 => Booting Puma => Rails 5.2.4 application starting in development => Run `rails server -h` for more startup options Puma starting in single mode... * Version 3.12.2 (ruby 2.6.3-p62), codename: Llamas in Pajamas * Min threads: 5, max threads: 5 * Environment: development * Listening on tcp://0.0.0.0:3000 Use Ctrl-C to stop