Odin-Facebook by Jamesredux

Please log in to see features

Ruby on Rails Final Project as part of the Odin Project

Assignment: Build Facebook! You'll build a large portion of the core Facebook user functionality in this project. We won't be worrying about the Javascript-heavy front end stuff but you won't need it to get a nice user experience. You should write at least a basic set of integration tests which let you know if each page is loading properly and unit tests to make sure your associations have been properly set up (e.g. testing that `User.first.posts` works properly).

The criteria set by the project were...

1. Use Postgresql for your database from the beginning (not sqlite3), that way your deployment to Heroku will go much more smoothly:

Done this, also created the app in Rails 6 to give me experience of working with that release.

2. Users must sign in to see anything except the sign in page.

Here we are! Anyone can create an account above but email confirmation is active.

3. User sign-in should use the Devise gem.

Used the devise gem, added some further authentifications - created some difficulties with facebook login below

4. Users can send Friend Requests to other Users.

5. A User must accept the Friend Request to become friends.

Users can also decline requests

6. The Friend Request shows up in the notifications section of a User's navbar.

7. Users can create Posts (text only to start). 8. Users can Like Posts. 9. Users can Comment on Posts. 10. Posts should always display with the post content, author, comments and likes.

This was completed, like/unlike button done with ajax. List of likers added with links to their accounts

11. Treat the Posts Index page like the real Facebook's "Timeline" feature -- show all the recent posts from the current user and users she is friends with.

Done, mixture of users posts and all his/her friends posts mixed together. Most recent at the top.

12. Users can create a Profile with a Photo (just start by using the Gravatar image like you did in the Rails Tutorial).

Users can use Gravatar or upload their own pictures.

13. The User Show page contains their Profile information, photo, and Posts. 14. The Users Index page lists all users and buttons for sending Friend Requests to those who are not already friends or who don't already have a pending request.

15. Sign in should use Omniauth to allow a user to sign in with their real Facebook account.

This was pretty tricky but I think I have got it working - facebook has changed some of the settings regarding this.

16. Set up a mailer to send a welcome email when a new user signs up.

Set up mailer and integrated Devise so user has to confirm email, and confirm change of password by email

17. Deploy your App to Heroku.

Here we are!

18. Set up the SendGrid add-on and start sending real emails. It's free for low usage tiers.

Done - Real emails are sent in production.

Extra Credit

1. Make posts also allow images (either just via a URL or, more complicated, by uploading one). 2. Use the Active Storage to allow users to upload a photo to their profile.

Users can do this. Upload photos with their post or for their profile picture. There are size limits, it uses Active Storage

3. Make your post able to be either a text OR a photo by using a polymorphic association (so users can still like or comment on it while being none-the-wiser).

I did this by making posts and pictures separate models so that likes and comments would have polymorphic associations with them. I think I made this more complicated then it needed to be.

4. Style it up nicely! We'll dive into HTML/CSS in the next course.

I styled it up a bit

Some of the gems used, see gemfile for full details

  • gem 'omniauth-facebook' - For facebook login
  • gem 'bcrypt', '3.1.12' - For hashing passwords
  • gem 'faker', '2.1.2' - to create dummy users and posts
  • gem 'kaminari' - to paginate records
  • gem 'aws-sdk-s3', '1.46.0' - for Amazon web storage
  • gem 'image_processing', '1.9.3' - for processing and manipulating image uploads
  • gem 'mini_magick', '4.9.5' - as above transforms images
  • gem 'active_storage_validations', '0.8.2'- for validating active storage uploads
  • gem 'figaro', '~> 1.0.0' - for storing api keys securely
  • gem 'letter_opener' - for dealings with mailer in development
  • gem 'guard' - for testing