Rails Project

Huy Do
2 min readMay 7, 2020

The project idea was inspired by the Amazon website. I created the ERD (Entity Relationship Diagram) with Lucidchart and google document as my project references. This helped me to identify which generator, model, and CRUD that I need for my project. Then I created a new rails project, local repo, and commit it to Github by using Github Desktop.

rails new shopping-cartgit init
git add .
git commit -m "first commit"
git remote add origin git@github.com:HuydDo/shopping-app.git
git push -u origin master

I created a rails generator to create resource and mode then migrate them.

rails g resource User --no-test-framework
rails g resource Item --no-test-framework
rails d resource User
rails g model Order --no-test-framework
rail db:migrate

I have spent some time to install Webpacker with Rails 6.0. I have to install Yarn version by:

//pwd
//home/huyddo
curl --compressed -o- -L https://yarnpkg.com/install.sh | bash

Open a new terminal to install it and check the version. Then install a webpacker.

//yarn --version
1.19.2
//cd shopping-app (master)
//rails webpacker:install

I have learned the benefits of using the nested resource, helper methods, and scope when I build my project. It took me a lot of time to understand the nested resource and scope method. I was also able to set up user authentication, including signup, login, logout, and passwords, and log in by Facebook.

It was interesting to learn how to display error messages through in the views and using Flash message in the controllers. I have used DRY by using partials form, helper methods for my views, and create logic in models

I have spent quite some time creating data by using the terminal and checking the data with DB Browser for SQLite. This helped me to understand better how to create data through active record association. I saved time by creating a seed file, and using rails migrate and rails generator commands.

In conclusion, this project helped me to understand how to create the full rails application by using CRUD, nested resource, log in/sign up, log in by different services, create and update data dynamically. I wish I have more time to add additional features to my app such as making payment after checking out the order, add more icons, styling and dynamic response web page.

Resources

https://guides.rubyonrails.org/active_record_querying.html#scopes

https://medium.com/@kevinyckim33/rails-generators-cli-cheatsheet-711295e7a1ed

https://medium.com/@theresamorelli/collection-select-what-the-heck-4e1cabc4be4b

http://www.xyzpub.com/en/ruby-on-rails/3.2/seed_rb.html

https://www.learnhowtoprogram.com/rails/ruby-on-rails-basics/database-scopes-and-queries

https://www.youtube.com/watch?v=FWIXWutlxIg

--

--

Huy Do
0 Followers

Full Stack SE. I love to build beautiful web apps and learn new technologies.