These are the notes I took while going through this free Ruby on Rails course: https://www.youtube.com/watch?v=fmyvWz5TUWg
Install everything here: https://guides.rubyonrails.org/getting_started.html
command curl -sSL https://rvm.io/pkuczynski.asc | gpg --import -
\curl -L https://get.rvm.io | bash -s stable
source /Users/mgwozdz/.rvm/scripts/rvm
rvm | head -n 1
rvm use ruby --install --default
gem install rails
rails --version
rails new <project name>
rails s
rails g controller home index
rails routes
rails g scaffold roster first_name:string last_name:string email:string phone:string
rails db:migrate
rubygems.org
search for devise
copy version line into Gemfile
bundle install
On rubygems.org, click on the Documentation for devise
rails generate devise:install
Follow the instructions that were output, including:
rails g devise:views
rails generate devise User
rails db:migrate
https://edgeguides.rubyonrails.org/association_basics.html
In roster data model, add belongs_to :user.
In user data model, add has_many :rosters
In terminal, generate migration to add user_id to rosters table as an index. Then push the migration.
rails g migration add_user_id_to_rosters user_id:integer:index
rails db:migrate
Google "heroku toolbelt" to find the Heroku CLI
Install the CLI
Verify the installation by typing heroku --version in the terminal
There will be a warning and a version in the output
Sign up for a free account at heroku.com
In the terminal, enter heroku login to login to the CLI
heroku create
This will output the url for your app. You can change the name of the app...
heroku rename railsroster
The url for the app is now https://railsroster.herokuapp.com/
Add your SSH keys:
heroku keys:add
Switch the sqlite3 gem to only be used in development and create a new group in the Gemfile for production and have it use the postgres (pg) gem instead.
bundle install --without production
Commit your changes to git with the usual git add ., git commit -am 'added pg to production', git push
Push to heroku with git push heroku main
If there are errors, follow the instructions in the output to resolve them. Then commit the changes and push them to main and retry the push to heroku.
Push database migrations to heroku: heroku run rails db:migrate
Your app should now be running on https://railsroster.herokuapp.com/