The Ruby on Rails capstone project (remember what they are?) is about building a mobile web application where you can manage your budget: you have a list of transactions associated with a category, so that you can see how much money you spent and on what.
-
I created a Ruby on Rails application that allows the user to:
- register and log in, so that the data is private to them.
- introduce new transactions associated with a category.
- see the money spent on each category.
Categories
Category-Details
- Use ruby gems as software packages system.
- Install Ruby on Rails framework.
- Understand Rails RESTful design and router.
- Use controllers to handle requests and render empty views.
- Use params from browser request in a safe way.
- Use preprocessed html file with embedded Ruby code.
- Use layouts and templates for shared content.
- Use database migration files to maintain database schema.
- Use validations for models.
- Secure app from n+1 problems.
- Understand what ORM is.
- Write SQL queries with ActiveRecord.
- Set up associations between models.
- uild a webapp that requires the user to log in.
- Use devise gem for authentication.
- Limit access to webapp resources based on authorization rules.
- Analyze in writing why you have made a coding choice using one structure over another.
To get a local copy for this project and running follow these simple example steps.
- You need to have git installed in your machine.
- Install a recent version of Postgres.
- Already install Rails
- The postgres installation doesn't setup a user for you, so you'll need to follow these steps to create a user with permission to create databases
$ sudo -u postgres createuser blog-app -s
- To create project with PostgreSQL database
$ rails new Rails-capstone-Budgy-Budget --database=postgresql #or
$ rails new Rails-capstone-Budgy-Budget -d postgresql
$ cd Rails-capstone-Budget-app # Move into the application directory
$ git clone https://github.com/evans22j/Budget-App.git
$ cd Budget-App
$ rails db:create # or
$ rake db:create
- Rubocop gem
$ bundle init
$ bundle install
- Stylelint package
$ npm init -y
$ npm install
$ npm install --save-dev [email protected] [email protected] [email protected] [email protected]
- Run linter
$ rubocop .
$ npx stylelint "**/*.{css,scss}"
- In auto-correct mode, RuboCop will try to automatically fix offenses:
$ rubocop -A # or
$ rubocop --auto-correct-all
$ npx stylelint "**/*.{css,scss}" --fix
$ rails s # or
$ rails server # or
$ rails server -p3001
- To restart the server
$ sudo service postgresql restart
$ rails db:reset #to clean the database
- You can now visit
http://localhost:3000
to view your new website!
You can also execute the rails routes
command in your terminal to produce the same output.
- At the first you need to include those lines in your Gemfile
gem 'rails-controller-testing'
gem 'rspec-rails'
$ rails generate rspec:install
-
This should generate some files that you will need to run your tests and should give us a Controller and a View
-
Then run:
$ rspec spec # to test if your tests are passed
$ rails g scaffold category name user:belongs_to
$ rails g scaffold records name amount:decimal user:belongs_to
$ rails g scaffold category_records user:belongs_to
$ rails g scaffold category_records category:belongs_to record:belongs_to
- To push the Migration into the database
$ rails db:migrate
- We use the seeds.rb file to records in the database
- To drop, create a table and to migrate and send the seed into the database:
$ rails db:drop db:create db:migrate db:seed
- To check available routes
$ rails routes
$ bundle exec rspec ./spec/features/
$ bundle exec rspec ./spec/models/
This project is build with:
π€ Evans Sitibekiso
- GitHub: @evans22j
- Twitter: @Evans_22J
- LinkedIn: @Evans Sitibekiso
Contributions, issues, and feature requests are welcome!
Feel free to check the issues page.
Give a βοΈ if you like this project!
- Credit to Gregoire Vella on Behance, the author of the original design guidelines
This project is MIT licensed.