Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.
/ gratify-me Public archive

A personal hub for your imagination

Notifications You must be signed in to change notification settings

JuzerShakir/gratify-me

Repository files navigation

Project: Gratify Me

A hub for keeping track of notes, quotes, and anything that is text-based.

wakatime

❗ Objectives

This web-app must accomplish the following:

  • Login users with social services (providers) such as Google, GitHub & Twitter with the help of Devise and Omniauth.
  • Make sure there's only one login created for each email regardless of which provider he/she uses.
  • If a user signs in with the same email but with a different provider, automatically sign in with the provider they logged in initially.
  • After user signs in, they can add more info about them via the Profile page.
  • Ability to add profile photos via Active Storage & Cloudinary and display photos on the page with a focus on the face.
  • Users can then add notes, quotes, etc to their feed. Show error when they try to add an empty post.
  • Show users' posts on their homepage sorted from the latest.
  • Provide users the ability to search words or expressions of the post they created through the Search Form gem.
  • Show appropriate flash messages wherever necessary.
  • Show sign-up count to logged-out users.
  • Build a responsive site using bootstrap.
  • When a user manually enters a URL that doesn't exist, redirect them to the homepage with a flash message informing them that the URL doesn't exist.

💎 Required Gems

This project was built on Ruby version 3.1.2.

Following important gems were installed in these versions:

Gem Names Gem Version Use
Rails 'rails' 6.1.7.2 Use for executing and rendering web-app
Postgresql 'pg' 1.2.3 Use postgres as the database for Active Record
Bootstrap 'bootstrap-sass' 3.4.1 For SCSS Styling
Devise 'devise' 4.8.0 Flexible authentication solution
Omniauth 'omniauth' 2.0.4 Authenticate via Social logins
Cloudinary 'cloudinary' 1.21.0 A cloud service for storing user images
Simple Form 'simple_form' 5.1.0 Search query through attributes in database
Pagy 'pagy' 5.3.1 For Pagination

⚙️ Setting up a PostgreSQL user

If you don't have a user set on postgres, here's how to set new user:

sudo -u postgres createuser -s [username]

To set a password for this user, log in to the PostgreSQL command line client:

sudo -u postgres psql

Enter the following command to set the password:

\password your_password

Enter and confirm the password. Then exit the PostgreSQL client:

\q

📋 Execution

Run the following commands to execute locally:

The following will install required version of ruby (make sure rvm is installed.)

rvm use 2.7.2
git clone git@github.com:JuzerShakir/gratify-me.git
cd gratify-me
bundle install

💡 Imp Note:

To successfully create development and test database, you will need to update config.database.yml file with correct postgresql username and password. To edit the it without exposing your credentials, give the following command:

EDITOR="code --wait" rails credentials:edit

code for Visual Studio Code subl for sublime

This will open credential.yml file and enter credential as follows in it:

database:
  username: your_username
  password: your_password

Hit ctrl + s to save and then close the credential.yml file from the editor. This will save the credentials. To check if it did save, run the following inside rails console:

Rails.application.credentials.dig(:database, :username)
rails db:create

To use Social Login services you will need to create apps for each provider you want to use to generate tokens and secret on their respective developer site.

After creating tokens and secrets for each provider, use credential.yml file to store the credentials :

provider:
  id: abcdefg
  secret: xxxxx

Replace provider with provider name such as google, twitter etc and enter your id and secret for respective providers.

The code in the config/initializers/devise.rb helps load these credentials for each provider.

To use cloudinary, make a cloudinary account. After creating, visit Dashboard page and just right to the 'Account Details' you will see Download YML, click on it and save the file in your config/ folder as cloudinary.yml file. Keep it as it is. DO NOT EDIT IT!

After setting up all this, you're ready to use this webapp.

rails s