๐ปA treat for those who'd like to make a ruby CLI but don't know where to start.
Ruby 100.00%
ruby-cli-setup's Introduction
Process
NOTE
this setup contains a rakefile with helpful process reminders
Setup
Create Gemfile + run bundle
Create migrations: run rake db:create_migration and add the syntax you need (e.g. NAME=create_users)
Migrate: run rake db:migrate
REMEMBER never ever ever change anything in schema.
Go to .bin/run.rb and change the name of the app on line 3 AND/OR go to Rakefile and change the name of the app on line 15
Go to ./app/models and change the names of the files (e.g. User.rb <- singular) and the class names inside
Set up association macros in classes (belongs_to / has_many / has_many, through:)
Create seed file in db/seed.rb + then run rake db:seed
remember: seeding does not give you any output so no news on your console == good news
Check if you've seeded correctly: run rake c and check what's the last instance of any of your class
Go to ./app/yourAppName.rb and change that file's name and whatever is inside (the class name should correspond to what you wrote in .bin/run.rb on line 3)
Coding
Create a dummy version of your logic -> hardcode it and don't yet make your code save anything to the database, just make sure that the logic works
Test often by running the file or by binding.pry
What I fould useful is drowing out every step I want to guide users through before coding - my whiteboard looked like this:
Then I coded the dummy version (without saving to the database, just to see if all "if"s are working and all that jazz)
Then I added the database manipulations.
Then I beautified the code and the app to make it visually pleasing