- Needs the
pg
gem as heroku uses PostgreSQL - Install heroku cli
- from command line, run
heroku login -i
, enteremail
and then enter authorization token (found atAccount settings -> Applications
) aspassword
- for dev and test & env, sqlite3 database and for prod, prostgresql is used (see
config/database.yml
)
- to create scffolded model:
rails generate scaffold <Model name in plural form> <attr1:data_type> <attr2:data_type>...<attrn, data_type>
- open console:
rails console
Following the tab;e
Full Command | Shortcut |
---|---|
$ rails server |
$ rails s |
$ rails console |
$ rails c |
$ rails generate |
$ rails g |
$ rails test |
$ rails t |
$ bundle install |
$ bundle |
- Creating controller, e.g
rails generate controller StaticPages home help
, whereStaticPages
is the controller andhome
andhelp
are action methods - Creating model, e.g
rails generate model User name:string email:string
, whereUser
is the model andname
,email
are the attributes - Destroy controller/model, e.g
rails destroy controller StaticPages home help
/rails destroy model User
- DB migration, e.g
rails db:migrate
- We can undo a single migration step using,
rails db:rollback
- To go all the way back to the beginning, we can use,
rails db:migrate VERSION=0
- If the ruby version is
<3.0.0
, update ruby withrbenv
- From command line, run,
bin/rails server