1. start a new project
rails new project_name
2. create scaffolds for your project, and notice your schema of the model
rails generate scaffold scaffolding_name schema_name:schema_type
ps1. if model_name is Photo, then table_name would be photos, controller_name would be PhotosController, and scaffolding_name would be photo. This is what we call "convention"!
ps2. after we use scaffolds, we will get MVC, but the database is not generated yet until we use migrate command
ps3. there is no int in schema_type, use integer instead
3. create database
rails db:migrate
沒有留言:
張貼留言