Library Management System - Ruby on Rails
- Signup/Login users
- Books CRUD
- Mail book details to user (Async)
- Subject-wise Categorization of Books
- Carrierwave
- mini_magick
- file_validators
- devise
- sidekiq
git clone http://www.github.com/maanavshah/library-management
cd library-management
bundle install
rake db:create
rake db:migrate
rails s
- Create project:
$ rails new library-management
- Setup Postgres
- Create a postgres user
$ sudo -u postgres createuser maanavshah -s
- Login to psql
$ sudo -u postgres psql
- Set user's password
\password maanavshah
- Add the following line to gemfile
gem 'pg'
-
Update the database.yml for postgres
-
Setup library-management database
$ rake db:create
$ rake db:migrate
- Generate Book and Subject model
$ rails generate model Book
$ rails generate model Subject
- Generate Book and Subject migration
$ rails generate migration books
$ rails generate migration subjects
$ rails db:migrate
- Generate controller
$ rails generate controller Book
- Add Carrierwave for image storage
https://code.tutsplus.com/articles/uploading-with-rails-and-carrierwave--cms-28409
$ rails generate uploader Image
$ rails generate migration add_image_to_books image:string
$ rake db:migrate
- Add Minimagic to generate thumbnail and support carrierwave
If images are already uploaded then run:
$ rails c
Book.find_each {|book| book.image.recreate_versions!(:thumb) if book.image?}
- Adding Devise and User
https://guides.railsgirls.com/devise
$ bundle install
$ rails g devise:install
Ensure you have defined default url options in your environments files. Open up config/environments/development.rb and add this line:
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
$ rails g devise user
$ rails db:migrate
- Add ActionMailer
$ rails generate mailer UserMailer
- Sidekiq with ActionMailer
https://gist.github.com/maxivak/690e6c353f65a86a4af9
You can create environment variables using:
http://railsapps.github.io/rails-environment-variables.html
https://devcenter.heroku.com/articles/getting-started-with-rails5
-
Login heroku
heroku login
-
Add heroku remote library-management
heroku git:remote -a library-management-7
-
Push code heroku master
git push heroku master
-
Add postgresql addon to heroku
heroku addons:create heroku-postgresql:hobby-dev
-
Rake setup (No need for rake db:create)
heroku run rake db:migrate
-
Add environment variables GMAIL
heroku config:add GMAIL_USERNAME=replymailer7@gmail.com heroku config:add GMAIL_PASSWORD=maanavshah@123
-
Scale Web application
heroku ps:scale web=1
-
Open website in browser
heroku open
-
Check Logs
heroku logs heroku logs --tail
-
Bundle rails console and sidekiq
heroku run bundle exec rails c heroku run bundle exec sidekiq
- devise - JWT (authentication and authorization)
- god - track sidekiq/nginx if disabled, then automatically re-enable
- foundation - bootstrap
- scss - sass mixin
- carrierwave - ActiveStorage
- state-machine
- kaminari
- turbolinks
- jbuilder