Skip to content

This project replicates the core functionality of Facebook using Ruby on Rails.

Notifications You must be signed in to change notification settings

rlmoser99/social-media

Repository files navigation

Facebook Clone

This is the final project in The Odin Project's Ruby on Rails curriculum.

Demo App

You can view this web app on Heroku. The heroku server will need a little bit of time to fire up a dyno, so please be patient with this free service.

If you would like to create reciprocal friendships, you may log in as any of the sample users. Please note: This sample data is reset daily, so any changes to friendships, posts, etc. will be deleted in the next 24 hours.

Email:

Sample usernames: malcolm, zoe, wash, inara, kaylee, river, simon, book, and jayne

Password:

serenity

Project Requirements

This project is to replicate the core functionality of Facebook using Ruby on Rails. It is not expected to use any JavaScript for this project.

Basic Features => Users should be able to:

  • Choose to sign in with Devise or their Facebook account.
  • Upload a profile picture.
  • Create posts.
  • Send and receive friendship requests.
  • View notifications of friendship requests.
  • View newsfeed of their friend's posts.
  • Comment on their friend's posts.
  • Like their friend's posts.

Extra credit features:

  • Allow users to have image-based or text-based posts.
  • Use ActiveStorage to handle image uploading.
  • Use Hotwire to handle real-time updates of posts, comments & likes.
  • Use a rake task to manage sample data.

Personal Lessons and Reflections

After completing the core project requirements, I decided to challenge myself with a few extra credit features. These features are where I really had to expand on the things that I've learned and read through a lot of new documentation.

Polymorphism

I learned a lot about polymorphic relationships during this project. Once I wrapped my head around it, I discovered the ability to use delegated_type which helped my views be more readable.

Cloudinary

I used ActiveStorage and Cloudinary to handle the images for the user's profile pictures and photo posts. I wasn't entirely sure where to begin so I used this article to point me the right direction. In hindsight, Cloudinary has great documentation and covered this same material thoroughly.

Testing

I learned how to test each feature as I built it. Most of the time, there was relevant documentation about testing. For example, the omniauth gem had great documentation on testing. Occasionally, I would have to do additional research, such as how to test ActiveStorage attachments or mailers.

Rake Tasks

Since anyone can sign in as a sample user to create reciprocal friendships, I am using a rake task rails db:populate_sample_data to automatically reset the database every day.

Hotwire & Turbo Streams

Even though this project specifically states to not worry about using JavaScript, I really wanted to see a comment or like appear without having to refresh the entire page. I've seen a lot of discussion about Hotwire lately, so I decided to give it a try! It doesn't work out-of-the-box with Devise and OmniAuth, so I had to use this GoRail's video and article to get it working correctly. In addition, I had to remove Devise's current_user from my views, because Hotwire requires partials to be free of global references.

Local Installation

  • Prerequisites: Rails, Git, and Bundler
  • Clone this repo (instructions)
  • Navigate into this project's directory cd social_media
  • Install the required gems, by running bundle install
  • This app uses figaro to manage secrets. You will need to create your own secrets for cloudinary, facebook, and gmail.
  • Create and seed the database, by running rails db:setup
  • Start the local server, by running rails server
  • View by visiting localhost:3000 in a web browser

Running the tests

  • To run the entire test suite

    rspec
    
  • You can specify one spec folder to run a group tests, such as

    rspec spec/system
    
  • You can specify one spec file to run a single set of tests, such as

    rspec spec/services/friendship_manager_spec.rb
    

About

This project replicates the core functionality of Facebook using Ruby on Rails.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published