├── LICENSE ├── log └── .keep ├── storage └── .keep ├── tmp └── .keep ├── vendor └── .keep ├── lib ├── assets │ ├── .keep │ └── Facebook_Clone_ERD.jpg └── tasks │ └── .keep ├── public ├── favicon.ico ├── apple-touch-icon.png ├── apple-touch-icon-precomposed.png ├── robots.txt ├── 500.html ├── 422.html └── 404.html ├── test ├── helpers │ └── .keep ├── mailers │ └── .keep ├── models │ ├── .keep │ ├── post_test.rb │ └── user_test.rb ├── system │ └── .keep ├── controllers │ ├── .keep │ ├── posts_controller_test.rb │ └── users_controller_test.rb ├── fixtures │ ├── .keep │ ├── files │ │ └── .keep │ ├── posts.yml │ └── users.yml ├── integration │ └── .keep ├── application_system_test_case.rb ├── channels │ └── application_cable │ │ └── connection_test.rb └── test_helper.rb ├── .ruby-version ├── app ├── assets │ ├── images │ │ └── .keep │ ├── config │ │ └── manifest.js │ └── stylesheets │ │ ├── likes.scss │ │ ├── comments.scss │ │ ├── users.scss │ │ ├── friendships.scss │ │ ├── posts.scss │ │ ├── application.css │ │ └── custom.scss ├── models │ ├── concerns │ │ └── .keep │ ├── application_record.rb │ ├── like.rb │ ├── comment.rb │ ├── post.rb │ ├── friendship.rb │ └── user.rb ├── controllers │ ├── concerns │ │ └── .keep │ ├── users_controller.rb │ ├── application_controller.rb │ ├── users │ │ └── omniauth_callbacks_controller.rb │ ├── comments_controller.rb │ ├── likes_controller.rb │ ├── posts_controller.rb │ └── friendships_controller.rb ├── views │ ├── comments │ │ ├── new.html.erb │ │ └── _comment.html.erb │ ├── posts │ │ ├── show.html.erb │ │ ├── index.html.erb │ │ ├── _new.html.erb │ │ └── _post.html.erb │ ├── layouts │ │ ├── mailer.text.erb │ │ ├── _footer.html.erb │ │ ├── mailer.html.erb │ │ ├── _header.html.erb │ │ └── application.html.erb │ ├── users │ │ ├── index.html.erb │ │ ├── show.html.erb │ │ └── _user.html.erb │ └── devise │ │ ├── mailer │ │ ├── password_change.html.erb │ │ ├── confirmation_instructions.html.erb │ │ ├── unlock_instructions.html.erb │ │ ├── email_changed.html.erb │ │ └── reset_password_instructions.html.erb │ │ ├── shared │ │ ├── _error_messages.html.erb │ │ └── _links.html.erb │ │ ├── unlocks │ │ └── new.html.erb │ │ ├── passwords │ │ ├── new.html.erb │ │ └── edit.html.erb │ │ ├── confirmations │ │ └── new.html.erb │ │ ├── sessions │ │ └── new.html.erb │ │ └── registrations │ │ ├── edit.html.erb │ │ └── new.html.erb ├── helpers │ ├── application_helper.rb │ ├── likes_helper.rb │ ├── posts_helper.rb │ ├── comments_helper.rb │ ├── friendships_helper.rb │ └── users_helper.rb ├── channels │ └── application_cable │ │ ├── channel.rb │ │ └── connection.rb ├── mailers │ └── application_mailer.rb ├── javascript │ ├── channels │ │ ├── index.js │ │ └── consumer.js │ └── packs │ │ └── application.js └── jobs │ └── application_job.rb ├── .browserslistrc ├── .rspec ├── config ├── webpack │ ├── environment.js │ ├── test.js │ ├── production.js │ └── development.js ├── spring.rb ├── environment.rb ├── initializers │ ├── mime_types.rb │ ├── filter_parameter_logging.rb │ ├── cookies_serializer.rb │ ├── application_controller_renderer.rb │ ├── backtrace_silencers.rb │ ├── wrap_parameters.rb │ ├── assets.rb │ ├── inflections.rb │ ├── content_security_policy.rb │ └── devise.rb ├── boot.rb ├── cable.yml ├── credentials.yml.enc ├── routes.rb ├── application.rb ├── locales │ ├── en.yml │ └── devise.en.yml ├── storage.yml ├── puma.rb ├── environments │ ├── test.rb │ ├── development.rb │ └── production.rb ├── webpacker.yml └── database.yml ├── config.ru ├── spec ├── controllers │ ├── likes_controller_spec.rb │ ├── comments_controller_spec.rb │ └── friendships_controller_spec.rb ├── helpers │ ├── likes_helper_spec.rb │ ├── comments_helper_spec.rb │ └── friendships_helper_spec.rb ├── models │ ├── post_spec.rb │ ├── like_spec.rb │ ├── friendship_spec.rb │ ├── comment_spec.rb │ └── user_spec.rb ├── features │ ├── facebook_login_spec.rb │ ├── sign_up_spec.rb │ ├── sign_in_spec.rb │ ├── comment_spec.rb │ ├── like_spec.rb │ └── friendship_spec.rb ├── rails_helper.rb └── spec_helper.rb ├── db ├── migrate │ ├── 20191120205645_add_name_to_users.rb │ ├── 20191130011500_add_omniauth_to_users.rb │ ├── 20191122153815_create_likes.rb │ ├── 20191121152153_create_posts.rb │ ├── 20191122153726_create_comments.rb │ ├── 20191126204605_create_friendships.rb │ └── 20191120195531_devise_create_users.rb ├── seeds.rb └── schema.rb ├── Rakefile ├── bin ├── rake ├── rails ├── yarn ├── webpack ├── webpack-dev-server ├── spring ├── setup └── bundle ├── postcss.config.js ├── package.json ├── .stickler.yml ├── .rubocop.yml ├── .gitignore ├── babel.config.js ├── Gemfile ├── Guardfile ├── README.md └── Gemfile.lock /LICENSE: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /storage/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tmp/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/helpers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/system/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.ruby-version: -------------------------------------------------------------------------------- 1 | 2.6.5 2 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/controllers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/fixtures/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/integration/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.browserslistrc: -------------------------------------------------------------------------------- 1 | defaults 2 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/apple-touch-icon.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/fixtures/files/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --require spec_helper 2 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/views/comments/new.html.erb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/views/posts/show.html.erb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/apple-touch-icon-precomposed.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.text.erb: -------------------------------------------------------------------------------- 1 | <%= yield %> 2 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/views/users/index.html.erb: -------------------------------------------------------------------------------- 1 |
Hello <%= @resource.email %>!
2 | 3 |We're contacting you to notify you that your password has been changed.
4 | -------------------------------------------------------------------------------- /spec/controllers/likes_controller_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'rails_helper' 4 | 5 | RSpec.describe LikesController, type: :controller do 6 | end 7 | -------------------------------------------------------------------------------- /spec/controllers/comments_controller_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'rails_helper' 4 | 5 | RSpec.describe CommentsController, type: :controller do 6 | end 7 | -------------------------------------------------------------------------------- /app/models/comment.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Comment < ApplicationRecord 4 | belongs_to :post 5 | belongs_to :user 6 | validates :content, presence: true 7 | end 8 | -------------------------------------------------------------------------------- /spec/controllers/friendships_controller_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'rails_helper' 4 | 5 | RSpec.describe FriendshipsController, type: :controller do 6 | end 7 | -------------------------------------------------------------------------------- /config/webpack/test.js: -------------------------------------------------------------------------------- 1 | process.env.NODE_ENV = process.env.NODE_ENV || 'development' 2 | 3 | const environment = require('./environment') 4 | 5 | module.exports = environment.toWebpackConfig() 6 | -------------------------------------------------------------------------------- /app/views/comments/_comment.html.erb: -------------------------------------------------------------------------------- 1 |Welcome <%= @email %>!
2 | 3 |You can confirm your account email through the link below:
4 | 5 |<%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %>
6 | -------------------------------------------------------------------------------- /app/assets/stylesheets/posts.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the Posts controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: https://sass-lang.com/ 4 | 5 | .post { 6 | border: 1px solid black; 7 | } 8 | -------------------------------------------------------------------------------- /app/views/posts/_new.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_with(model: Post, local: true) do |f| %> 2 | 3 | <%= f.label :Create_Post %> 4 | <%= f.text_field :content, placeholder: "What's on your mind?", class: 'post-form' %> 5 | 6 | <%= f.submit "Post!", class: "btn btn-primary" %> 7 | <% end %> -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [ 3 | require('postcss-import'), 4 | require('postcss-flexbugs-fixes'), 5 | require('postcss-preset-env')({ 6 | autoprefixer: { 7 | flexbox: 'no-2009' 8 | }, 9 | stage: 3 10 | }) 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Specify a serializer for the signed and encrypted cookie jars. 4 | # Valid options are :json, :marshal, and :hybrid. 5 | Rails.application.config.action_dispatch.cookies_serializer = :json 6 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path('../spring', __FILE__) 4 | rescue LoadError => e 5 | raise unless e.message.include?('spring') 6 | end 7 | APP_PATH = File.expand_path('../config/application', __dir__) 8 | require_relative '../config/boot' 9 | require 'rails/commands' 10 | -------------------------------------------------------------------------------- /config/initializers/application_controller_renderer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # ActiveSupport::Reloader.to_prepare do 4 | # ApplicationController.renderer.defaults.merge!( 5 | # http_host: 'example.org', 6 | # https: false 7 | # ) 8 | # end 9 | require 'dotenv/load' -------------------------------------------------------------------------------- /app/javascript/channels/consumer.js: -------------------------------------------------------------------------------- 1 | // Action Cable provides the framework to deal with WebSockets in Rails. 2 | // You can generate new channels where WebSocket features live using the `rails generate channel` command. 3 | 4 | import { createConsumer } from "@rails/actioncable" 5 | 6 | export default createConsumer() 7 | -------------------------------------------------------------------------------- /app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | # Automatically retry jobs that encountered a deadlock 3 | # retry_on ActiveRecord::Deadlocked 4 | 5 | # Most jobs are safe to ignore if the underlying records are no longer available 6 | # discard_on ActiveJob::DeserializationError 7 | end 8 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/controllers/users_controller.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class UsersController < ApplicationController 4 | before_action :authenticate_user! 5 | 6 | def index 7 | @users = User.all 8 | end 9 | 10 | def show 11 | @user = User.find(params[:id]) 12 | @posts = @user.posts 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /app/views/devise/mailer/unlock_instructions.html.erb: -------------------------------------------------------------------------------- 1 |Hello <%= @resource.email %>!
2 | 3 |Your account has been locked due to an excessive number of unsuccessful sign in attempts.
4 | 5 |Click the link below to unlock your account:
6 | 7 |<%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %>
8 | -------------------------------------------------------------------------------- /test/channels/application_cable/connection_test.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | 3 | class ApplicationCable::ConnectionTest < ActionCable::Connection::TestCase 4 | # test "connects with cookies" do 5 | # cookies.signed[:user_id] = 42 6 | # 7 | # connect 8 | # 9 | # assert_equal connection.user_id, "42" 10 | # end 11 | end 12 | -------------------------------------------------------------------------------- /bin/yarn: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_ROOT = File.expand_path('..', __dir__) 3 | Dir.chdir(APP_ROOT) do 4 | begin 5 | exec "yarnpkg", *ARGV 6 | rescue Errno::ENOENT 7 | $stderr.puts "Yarn executable was not detected in the system." 8 | $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" 9 | exit 1 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /db/migrate/20191122153815_create_likes.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreateLikes < ActiveRecord::Migration[6.0] 4 | def change 5 | create_table :likes do |t| 6 | t.references :post, null: false, foreign_key: true 7 | t.references :user, null: false, foreign_key: true 8 | 9 | t.timestamps 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /app/views/devise/mailer/email_changed.html.erb: -------------------------------------------------------------------------------- 1 |Hello <%= @email %>!
2 | 3 | <% if @resource.try(:unconfirmed_email?) %> 4 |We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.
5 | <% else %> 6 |We're contacting you to notify you that your email has been changed to <%= @resource.email %>.
7 | <% end %> 8 | -------------------------------------------------------------------------------- /db/migrate/20191121152153_create_posts.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreatePosts < ActiveRecord::Migration[6.0] 4 | def change 5 | create_table :posts do |t| 6 | t.string :content 7 | t.references :user, null: false, foreign_key: true 8 | 9 | t.timestamps 10 | end 11 | add_index :posts, %i[user_id created_at] 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /app/helpers/users_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module UsersHelper 4 | # Returns the Gravatar for the given user. 5 | def gravatar_for(user) 6 | gravatar_id = Digest::MD5.hexdigest(user.email.downcase) 7 | gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}" 8 | image_tag(gravatar_url, alt: user.name, class: 'gravatar') 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) 7 | # Character.create(name: 'Luke', movie: movies.first) 8 | -------------------------------------------------------------------------------- /db/migrate/20191122153726_create_comments.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreateComments < ActiveRecord::Migration[6.0] 4 | def change 5 | create_table :comments do |t| 6 | t.string :content 7 | t.references :post, null: false, foreign_key: true 8 | t.references :user, null: false, foreign_key: true 9 | 10 | t.timestamps 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ROR_Facebook_Clone", 3 | "private": true, 4 | "dependencies": { 5 | "@rails/actioncable": "^6.0.0", 6 | "@rails/activestorage": "^6.0.0", 7 | "@rails/ujs": "^6.0.0", 8 | "@rails/webpacker": "^4.2.0", 9 | "turbolinks": "^5.2.0" 10 | }, 11 | "version": "0.1.0", 12 | "devDependencies": { 13 | "webpack-dev-server": "^3.9.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/fixtures/posts.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 2 | 3 | # This model initially had no columns defined. If you add columns to the 4 | # model remove the '{}' from the fixture names and add the columns immediately 5 | # below each fixture, per the syntax in the comments below 6 | # 7 | one: {} 8 | # column: value 9 | # 10 | two: {} 11 | # column: value 12 | -------------------------------------------------------------------------------- /test/fixtures/users.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 2 | 3 | # This model initially had no columns defined. If you add columns to the 4 | # model remove the '{}' from the fixture names and add the columns immediately 5 | # below each fixture, per the syntax in the comments below 6 | # 7 | one: {} 8 | # column: value 9 | # 10 | two: {} 11 | # column: value 12 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | ENV['RAILS_ENV'] ||= 'test' 2 | require_relative '../config/environment' 3 | require 'rails/test_help' 4 | 5 | class ActiveSupport::TestCase 6 | # Run tests in parallel with specified workers 7 | parallelize(workers: :number_of_processors) 8 | 9 | # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. 10 | fixtures :all 11 | 12 | # Add more helper methods to be used by all tests here... 13 | end 14 | -------------------------------------------------------------------------------- /config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /app/views/devise/mailer/reset_password_instructions.html.erb: -------------------------------------------------------------------------------- 1 |Hello <%= @resource.email %>!
2 | 3 |Someone has requested a link to change your password. You can do this through the link below.
4 | 5 |<%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %>
6 | 7 |If you didn't request this, please ignore this email.
8 |Your password won't change until you access the link above and create a new one.
9 | -------------------------------------------------------------------------------- /config/credentials.yml.enc: -------------------------------------------------------------------------------- 1 | I/eJX1N6GS7YqHQffnZaVqfIcR1+L1YvIKtaK9QbZ4RxaO0IotRNn19xoR1+5dzKoIbZy8Kq9YCf5FncsdDAA/jveG65pLovJ3BNbnuFFC7TQhHArxznrANhy6a0dp2yamc1rqwi/S+6QY+gKhjpQgJcvMqxdUsmR0gQb3kWbG5dvYNzjMYflFDTScnbMmmnBCijqaxjU2ELoiwunTFo0rRzJm6kGaoZojlpHWv7icxFpud0Q0DVAsPhMYTAk9NejQPiEaW4q9GPqWgUwhO3cleKbIVEHEhfgP0OT5IFMZYJJyBiK0aFbVGLYQglT7h0vu7HUxF3nklqUTMSzRERvhCpPrnry6H9XEb6UZvaH2bv1WsULmvLkU9YxSicLI32EnaGaBagQx2tKp0p7FAU2WE3DqHeYXobTdJi--+20TwwCiBdi1Zdnk--zcOCXQWhw4e2NSdJ31Nbnw== -------------------------------------------------------------------------------- /bin/webpack: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development" 4 | ENV["NODE_ENV"] ||= "development" 5 | 6 | require "pathname" 7 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", 8 | Pathname.new(__FILE__).realpath) 9 | 10 | require "bundler/setup" 11 | 12 | require "webpacker" 13 | require "webpacker/webpack_runner" 14 | 15 | APP_ROOT = File.expand_path("..", __dir__) 16 | Dir.chdir(APP_ROOT) do 17 | Webpacker::WebpackRunner.run(ARGV) 18 | end 19 | -------------------------------------------------------------------------------- /db/migrate/20191126204605_create_friendships.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreateFriendships < ActiveRecord::Migration[6.0] 4 | def change 5 | create_table :friendships do |t| 6 | t.references :user, index: true, foreign_key: true 7 | t.references :friend, index: true 8 | t.boolean :confirmed, null: false, default: false 9 | 10 | t.timestamps null: false 11 | end 12 | add_foreign_key :friendships, :users, column: :friend_id 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /spec/helpers/likes_helper_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'rails_helper' 4 | 5 | # Specs in this file have access to a helper object that includes 6 | # the LikesHelper. For example: 7 | # 8 | # describe LikesHelper do 9 | # describe "string concat" do 10 | # it "concats two strings with spaces" do 11 | # expect(helper.concat_strings("this","that")).to eq("this that") 12 | # end 13 | # end 14 | # end 15 | RSpec.describe LikesHelper, type: :helper do 16 | end 17 | -------------------------------------------------------------------------------- /app/views/devise/shared/_error_messages.html.erb: -------------------------------------------------------------------------------- 1 | <% if resource.errors.any? %> 2 |<%= post.content %>
5 |
6 | <% pre_like = post.likes.find { |like| like.user_id == current_user.id} %>
7 | <% if pre_like %>
8 | <%= form_with(model:Like, method: :delete, remote: true) do |f| %>
9 | <%= f.hidden_field :post_id, value: post.id %>
10 | <%= f.submit 'Unlike', class: "btn btn-primary" %>
11 | <% end %>
12 | <% else %>
13 | <%= form_with(model:Like, method: :post) do |f| %>
14 | <%= f.hidden_field :post_id, value: post.id %>
15 | <%= f.submit 'Like', class: "btn btn-primary" %>
16 | <% end %>
17 | <% end %>
18 |
19 | <%= post.likes.count %> <%= (post.likes.count) == 1 ? 'Like' : 'Likes'%>
20 | <% if post.comments.any? %>
21 | <%= post.comments.count %> <%= (post.comments.count) == 1 ? 'Comment' : 'Comments'%>
22 |
Comments:
23 |
Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %>
42 | 43 | <%= link_to "Back", :back %> 44 | -------------------------------------------------------------------------------- /config/puma.rb: -------------------------------------------------------------------------------- 1 | # Puma can serve each request in a thread from an internal thread pool. 2 | # The `threads` method setting takes two numbers: a minimum and maximum. 3 | # Any libraries that use thread pools should be configured to match 4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum 5 | # and maximum; this matches the default thread size of Active Record. 6 | # 7 | max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } 8 | min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } 9 | threads min_threads_count, max_threads_count 10 | 11 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000. 12 | # 13 | port ENV.fetch("PORT") { 3000 } 14 | 15 | # Specifies the `environment` that Puma will run in. 16 | # 17 | environment ENV.fetch("RAILS_ENV") { "development" } 18 | 19 | # Specifies the `pidfile` that Puma will use. 20 | pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } 21 | 22 | # Specifies the number of `workers` to boot in clustered mode. 23 | # Workers are forked web server processes. If using threads and workers together 24 | # the concurrency of the application would be max `threads` * `workers`. 25 | # Workers do not work on JRuby or Windows (both of which do not support 26 | # processes). 27 | # 28 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 } 29 | 30 | # Use the `preload_app!` method when specifying a `workers` number. 31 | # This directive tells Puma to first boot the application and load code 32 | # before forking the application. This takes advantage of Copy On Write 33 | # process behavior so workers use less memory. 34 | # 35 | # preload_app! 36 | 37 | # Allow puma to be restarted by `rails restart` command. 38 | plugin :tmp_restart 39 | -------------------------------------------------------------------------------- /app/views/users/_user.html.erb: -------------------------------------------------------------------------------- 1 |If you are the application owner check the logs for more information.
64 |See photos and updates from friends in News Feed.
Share what's new in your life on your Timeline.
Find more of what you're looking for with Facebook Search.
8 |It’s quick and easy.
Maybe you tried to change something you didn't have access to.
63 |If you are the application owner check the logs for more information.
65 |You may have mistyped the address or the page may have moved.
63 |If you are the application owner check the logs for more information.
65 |2 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
103 | 104 | andresmoya.me 105 | 106 |
107 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # 5 | # This file was generated by Bundler. 6 | # 7 | # The application 'bundle' is installed as part of a gem, and 8 | # this file is here to facilitate running it. 9 | # 10 | 11 | require "rubygems" 12 | 13 | m = Module.new do 14 | module_function 15 | 16 | def invoked_as_script? 17 | File.expand_path($0) == File.expand_path(__FILE__) 18 | end 19 | 20 | def env_var_version 21 | ENV["BUNDLER_VERSION"] 22 | end 23 | 24 | def cli_arg_version 25 | return unless invoked_as_script? # don't want to hijack other binstubs 26 | return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` 27 | bundler_version = nil 28 | update_index = nil 29 | ARGV.each_with_index do |a, i| 30 | if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN 31 | bundler_version = a 32 | end 33 | next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ 34 | bundler_version = $1 || ">= 0.a" 35 | update_index = i 36 | end 37 | bundler_version 38 | end 39 | 40 | def gemfile 41 | gemfile = ENV["BUNDLE_GEMFILE"] 42 | return gemfile if gemfile && !gemfile.empty? 43 | 44 | File.expand_path("../../Gemfile", __FILE__) 45 | end 46 | 47 | def lockfile 48 | lockfile = 49 | case File.basename(gemfile) 50 | when "gems.rb" then gemfile.sub(/\.rb$/, gemfile) 51 | else "#{gemfile}.lock" 52 | end 53 | File.expand_path(lockfile) 54 | end 55 | 56 | def lockfile_version 57 | return unless File.file?(lockfile) 58 | lockfile_contents = File.read(lockfile) 59 | return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ 60 | Regexp.last_match(1) 61 | end 62 | 63 | def bundler_version 64 | @bundler_version ||= begin 65 | env_var_version || cli_arg_version || 66 | lockfile_version || "#{Gem::Requirement.default}.a" 67 | end 68 | end 69 | 70 | def load_bundler! 71 | ENV["BUNDLE_GEMFILE"] ||= gemfile 72 | 73 | # must dup string for RG < 1.8 compatibility 74 | activate_bundler(bundler_version.dup) 75 | end 76 | 77 | def activate_bundler(bundler_version) 78 | if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0") 79 | bundler_version = "< 2" 80 | end 81 | gem_error = activation_error_handling do 82 | gem "bundler", bundler_version 83 | end 84 | return if gem_error.nil? 85 | require_error = activation_error_handling do 86 | require "bundler/version" 87 | end 88 | return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION)) 89 | warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`" 90 | exit 42 91 | end 92 | 93 | def activation_error_handling 94 | yield 95 | nil 96 | rescue StandardError, LoadError => e 97 | e 98 | end 99 | end 100 | 101 | m.load_bundler! 102 | 103 | if m.invoked_as_script? 104 | load Gem.bin_path("bundler", "bundle") 105 | end 106 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | # PostgreSQL. Versions 9.3 and up are supported. 2 | # 3 | # Install the pg driver: 4 | # gem install pg 5 | # On macOS with Homebrew: 6 | # gem install pg -- --with-pg-config=/usr/local/bin/pg_config 7 | # On macOS with MacPorts: 8 | # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config 9 | # On Windows: 10 | # gem install pg 11 | # Choose the win32 build. 12 | # Install PostgreSQL and put its /bin directory on your path. 13 | # 14 | # Configure Using Gemfile 15 | # gem 'pg' 16 | # 17 | default: &default 18 | adapter: postgresql 19 | encoding: unicode 20 | # For details on connection pooling, see Rails configuration guide 21 | # https://guides.rubyonrails.org/configuring.html#database-pooling 22 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 23 | 24 | development: 25 | <<: *default 26 | database: ROR_Facebook_Clone_development 27 | 28 | # The specified database role being used to connect to postgres. 29 | # To create additional roles in postgres see `$ createuser --help`. 30 | # When left blank, postgres will use the default role. This is 31 | # the same name as the operating system user that initialized the database. 32 | #username: ROR_Facebook_Clone 33 | 34 | # The password associated with the postgres role (username). 35 | #password: 36 | 37 | # Connect on a TCP socket. Omitted by default since the client uses a 38 | # domain socket that doesn't need configuration. Windows does not have 39 | # domain sockets, so uncomment these lines. 40 | #host: localhost 41 | 42 | # The TCP port the server listens on. Defaults to 5432. 43 | # If your server runs on a different port number, change accordingly. 44 | #port: 5432 45 | 46 | # Schema search path. The server defaults to $user,public 47 | #schema_search_path: myapp,sharedapp,public 48 | 49 | # Minimum log levels, in increasing order: 50 | # debug5, debug4, debug3, debug2, debug1, 51 | # log, notice, warning, error, fatal, and panic 52 | # Defaults to warning. 53 | #min_messages: notice 54 | 55 | # Warning: The database defined as "test" will be erased and 56 | # re-generated from your development database when you run "rake". 57 | # Do not set this db to the same as development or production. 58 | test: 59 | <<: *default 60 | database: ROR_Facebook_Clone_test 61 | 62 | # As with config/credentials.yml, you never want to store sensitive information, 63 | # like your database password, in your source code. If your source code is 64 | # ever seen by anyone, they now have access to your database. 65 | # 66 | # Instead, provide the password as a unix environment variable when you boot 67 | # the app. Read https://guides.rubyonrails.org/configuring.html#configuring-a-database 68 | # for a full rundown on how to provide these environment variables in a 69 | # production deployment. 70 | # 71 | # On Heroku and other platform providers, you may have a full connection URL 72 | # available as an environment variable. For example: 73 | # 74 | # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase" 75 | # 76 | # You can use this database configuration with: 77 | # 78 | # production: 79 | # url: <%= ENV['DATABASE_URL'] %> 80 | # 81 | production: 82 | <<: *default 83 | database: ROR_Facebook_Clone_production 84 | username: ROR_Facebook_Clone 85 | password: <%= ENV['ROR_FACEBOOK_CLONE_DATABASE_PASSWORD'] %> 86 | -------------------------------------------------------------------------------- /db/schema.rb: -------------------------------------------------------------------------------- 1 | # This file is auto-generated from the current state of the database. Instead 2 | # of editing this file, please use the migrations feature of Active Record to 3 | # incrementally modify your database, and then regenerate this schema definition. 4 | # 5 | # This file is the source Rails uses to define your schema when running `rails 6 | # db:schema:load`. When creating a new database, `rails db:schema:load` tends to 7 | # be faster and is potentially less error prone than running all of your 8 | # migrations from scratch. Old migrations may fail to apply correctly if those 9 | # migrations use external dependencies or application code. 10 | # 11 | # It's strongly recommended that you check this file into your version control system. 12 | 13 | ActiveRecord::Schema.define(version: 2019_11_30_011500) do 14 | 15 | # These are extensions that must be enabled in order to support this database 16 | enable_extension "plpgsql" 17 | 18 | create_table "comments", force: :cascade do |t| 19 | t.string "content" 20 | t.bigint "post_id", null: false 21 | t.bigint "user_id", null: false 22 | t.datetime "created_at", precision: 6, null: false 23 | t.datetime "updated_at", precision: 6, null: false 24 | t.index ["post_id"], name: "index_comments_on_post_id" 25 | t.index ["user_id"], name: "index_comments_on_user_id" 26 | end 27 | 28 | create_table "friendships", force: :cascade do |t| 29 | t.bigint "user_id" 30 | t.bigint "friend_id" 31 | t.boolean "confirmed", default: false, null: false 32 | t.datetime "created_at", precision: 6, null: false 33 | t.datetime "updated_at", precision: 6, null: false 34 | t.index ["friend_id"], name: "index_friendships_on_friend_id" 35 | t.index ["user_id"], name: "index_friendships_on_user_id" 36 | end 37 | 38 | create_table "likes", force: :cascade do |t| 39 | t.bigint "post_id", null: false 40 | t.bigint "user_id", null: false 41 | t.datetime "created_at", precision: 6, null: false 42 | t.datetime "updated_at", precision: 6, null: false 43 | t.index ["post_id"], name: "index_likes_on_post_id" 44 | t.index ["user_id"], name: "index_likes_on_user_id" 45 | end 46 | 47 | create_table "posts", force: :cascade do |t| 48 | t.string "content" 49 | t.bigint "user_id", null: false 50 | t.datetime "created_at", precision: 6, null: false 51 | t.datetime "updated_at", precision: 6, null: false 52 | t.index ["user_id", "created_at"], name: "index_posts_on_user_id_and_created_at" 53 | t.index ["user_id"], name: "index_posts_on_user_id" 54 | end 55 | 56 | create_table "users", force: :cascade do |t| 57 | t.string "email", default: "", null: false 58 | t.string "encrypted_password", default: "", null: false 59 | t.string "reset_password_token" 60 | t.datetime "reset_password_sent_at" 61 | t.datetime "remember_created_at" 62 | t.datetime "created_at", precision: 6, null: false 63 | t.datetime "updated_at", precision: 6, null: false 64 | t.string "name" 65 | t.string "provider" 66 | t.string "uid" 67 | t.index ["email"], name: "index_users_on_email", unique: true 68 | t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true 69 | end 70 | 71 | add_foreign_key "comments", "posts" 72 | add_foreign_key "comments", "users" 73 | add_foreign_key "friendships", "users" 74 | add_foreign_key "friendships", "users", column: "friend_id" 75 | add_foreign_key "likes", "posts" 76 | add_foreign_key "likes", "users" 77 | add_foreign_key "posts", "users" 78 | end 79 | -------------------------------------------------------------------------------- /app/assets/stylesheets/custom.scss: -------------------------------------------------------------------------------- 1 | @import "bootstrap-sprockets"; 2 | @import "bootstrap"; 3 | 4 | // Variables 5 | $facebook: #000000; 6 | $entrance: #edf0f5; 7 | 8 | // Header 9 | header { 10 | background-color: $facebook; 11 | font-weight: bold; 12 | font-size: 3rem; 13 | color: white; 14 | height: 8rem; 15 | div { 16 | font-size: 2rem; 17 | width: 25%; 18 | } 19 | } 20 | .fb { 21 | float: left; 22 | left: 2.5rem; 23 | position: relative; 24 | top: 1.5rem; 25 | } 26 | .top-panel { 27 | float: right; 28 | position: relative; 29 | right: -5rem; 30 | top: 1rem; 31 | width: 42%; 32 | span { 33 | font-size: 1.7rem; 34 | padding: 0.5rem; 35 | a { 36 | color: white; 37 | &:hover { color: rgb(127, 127, 179); } 38 | } 39 | } 40 | } 41 | 42 | // Body 43 | body { 44 | background-color: $entrance; 45 | overflow: scroll; 46 | max-width: 100%; 47 | } 48 | 49 | // Sign Up Form 50 | .sign-back { 51 | background-color: $entrance; 52 | padding-bottom: 3rem; 53 | p { margin-left: 4rem; } 54 | } 55 | .clearfix { 56 | content: ""; 57 | clear: both; 58 | display: block; 59 | } 60 | .sign-left { 61 | float: left; 62 | padding: 4rem; 63 | width: 50%; 64 | } 65 | .sign-right { 66 | float: right; 67 | width: 50%; 68 | h2 { margin-left: 4rem; } 69 | .field { 70 | margin-left: 4rem; 71 | } 72 | .login { 73 | font-weight: bold; 74 | } 75 | } 76 | .form-area { 77 | border-radius: 10px; 78 | border: none; 79 | height: 3rem; 80 | width: 30rem; 81 | } 82 | .su-btn { 83 | background-color: RGB(74, 158, 59); 84 | color: white; 85 | font-weight: bold; 86 | } 87 | 88 | // Login Form 89 | 90 | .login-form { 91 | background-color: $entrance; 92 | text-align: center; 93 | padding: 2rem; 94 | padding-bottom: 4rem; 95 | color: #000000 96 | } 97 | 98 | .login-form a { 99 | color: #000000 100 | } 101 | 102 | // Footer (Login & Sign up) 103 | footer { 104 | padding: 0.1rem; 105 | } 106 | .ftr-1 { 107 | li { 108 | display: inline; 109 | color: #0e1f56; 110 | font-size: 1.15rem; 111 | padding-right: 2.5rem; 112 | &:hover { 113 | text-decoration: underline; 114 | } 115 | } 116 | p { 117 | font-size: 1.15rem; 118 | padding-top: 0.5rem; 119 | margin-left: 4rem; 120 | } 121 | } 122 | .lang { 123 | position: relative; 124 | top: 0.5rem; 125 | } 126 | 127 | // User's (show) Page 128 | 129 | .user { 130 | margin: 0 auto; 131 | width: 80%; 132 | } 133 | .show-stn-1 { 134 | background-color: white; 135 | height: 10rem; 136 | .inner { 137 | margin: 0 auto; 138 | width: 60%; 139 | } 140 | .user-img { 141 | position: relative; 142 | left: 30%; 143 | width: 15%; 144 | } 145 | .user-info { 146 | bottom: 8rem; 147 | position: relative; 148 | left: 45%; 149 | width: 40%; 150 | } 151 | } 152 | .show-stn-2 { 153 | background-color: white; 154 | h4 { margin-left: 1rem; } 155 | } 156 | .post-form { 157 | border-radius: 10px; 158 | height: 4rem; 159 | margin-left: 2rem; 160 | margin-right: 2rem; 161 | width: 70%; 162 | } 163 | .pt-fm { 164 | margin: 0 auto; 165 | padding-top: 2rem; 166 | width: 70%; 167 | } 168 | .post { 169 | padding: 1rem; 170 | } 171 | .post-content { font-size: 2rem; } 172 | .ind-post { 173 | background-color: white; 174 | border: 1px solid; 175 | padding-bottom: 2rem; 176 | padding-top: 2rem; 177 | margin-top: -0.9rem; 178 | } 179 | .user-name { font-size: 2.2rem; } 180 | .comm-label { 181 | font-weight: bold; 182 | text-decoration: underline; 183 | } 184 | .comm-no { margin: 1.2rem; } 185 | .comments { 186 | margin-left: -5rem; 187 | } 188 | .divider { margin-top: 1rem; } 189 | 190 | // User Index Page 191 | 192 | .u-index { 193 | border-bottom: 1px solid rgb(163, 161, 161); 194 | padding: 2rem; 195 | width: 50%; 196 | .u-name { 197 | bottom: 2rem; 198 | font-size: 2rem; 199 | left: 1rem; 200 | position: relative; 201 | } 202 | .u-btn { 203 | bottom: 3.5rem; 204 | left: 9.3rem; 205 | position: relative; 206 | } 207 | } 208 | 209 | // Post Index Page 210 | 211 | h1 { text-align: center; } 212 | 213 | -------------------------------------------------------------------------------- /config/locales/devise.en.yml: -------------------------------------------------------------------------------- 1 | # Additional translations at https://github.com/plataformatec/devise/wiki/I18n 2 | 3 | en: 4 | devise: 5 | confirmations: 6 | confirmed: "Your email address has been successfully confirmed." 7 | send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes." 8 | send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes." 9 | failure: 10 | already_authenticated: "You are already signed in." 11 | inactive: "Your account is not activated yet." 12 | invalid: "Invalid %{authentication_keys} or password." 13 | locked: "Your account is locked." 14 | last_attempt: "You have one more attempt before your account is locked." 15 | not_found_in_database: "Invalid %{authentication_keys} or password." 16 | timeout: "Your session expired. Please sign in again to continue." 17 | unauthenticated: "You need to sign in or sign up before continuing." 18 | unconfirmed: "You have to confirm your email address before continuing." 19 | mailer: 20 | confirmation_instructions: 21 | subject: "Confirmation instructions" 22 | reset_password_instructions: 23 | subject: "Reset password instructions" 24 | unlock_instructions: 25 | subject: "Unlock instructions" 26 | email_changed: 27 | subject: "Email Changed" 28 | password_change: 29 | subject: "Password Changed" 30 | omniauth_callbacks: 31 | failure: "Could not authenticate you from %{kind} because \"%{reason}\"." 32 | success: "Successfully authenticated from %{kind} account." 33 | passwords: 34 | no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided." 35 | send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes." 36 | send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes." 37 | updated: "Your password has been changed successfully. You are now signed in." 38 | updated_not_active: "Your password has been changed successfully." 39 | registrations: 40 | destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon." 41 | signed_up: "Welcome! You have signed up successfully." 42 | signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated." 43 | signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked." 44 | signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account." 45 | update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address." 46 | updated: "Your account has been updated successfully." 47 | updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again" 48 | sessions: 49 | signed_in: "Signed in successfully." 50 | signed_out: "Signed out successfully." 51 | already_signed_out: "Signed out successfully." 52 | unlocks: 53 | send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes." 54 | send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes." 55 | unlocked: "Your account has been unlocked successfully. Please sign in to continue." 56 | errors: 57 | messages: 58 | already_confirmed: "was already confirmed, please try signing in" 59 | confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one" 60 | expired: "has expired, please request a new one" 61 | not_found: "not found" 62 | not_locked: "was not locked" 63 | not_saved: 64 | one: "1 error prohibited this %{resource} from being saved:" 65 | other: "%{count} errors prohibited this %{resource} from being saved:" 66 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # Code is not reloaded between requests. 5 | config.cache_classes = true 6 | 7 | # Eager load code on boot. This eager loads most of Rails and 8 | # your application in memory, allowing both threaded web servers 9 | # and those relying on copy on write to perform better. 10 | # Rake tasks automatically ignore this option for performance. 11 | config.eager_load = true 12 | 13 | # Full error reports are disabled and caching is turned on. 14 | config.consider_all_requests_local = false 15 | config.action_controller.perform_caching = true 16 | 17 | # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] 18 | # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). 19 | # config.require_master_key = true 20 | 21 | # Disable serving static files from the `/public` folder by default since 22 | # Apache or NGINX already handles this. 23 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? 24 | 25 | # Compress CSS using a preprocessor. 26 | # config.assets.css_compressor = :sass 27 | 28 | # Do not fallback to assets pipeline if a precompiled asset is missed. 29 | config.assets.compile = false 30 | 31 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 32 | # config.action_controller.asset_host = 'http://assets.example.com' 33 | 34 | # Specifies the header that your server uses for sending files. 35 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache 36 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX 37 | 38 | # Store uploaded files on the local file system (see config/storage.yml for options). 39 | config.active_storage.service = :local 40 | 41 | # Mount Action Cable outside main process or domain. 42 | # config.action_cable.mount_path = nil 43 | # config.action_cable.url = 'wss://example.com/cable' 44 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] 45 | 46 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 47 | # config.force_ssl = true 48 | 49 | # Use the lowest log level to ensure availability of diagnostic information 50 | # when problems arise. 51 | config.log_level = :debug 52 | 53 | # Prepend all log lines with the following tags. 54 | config.log_tags = [ :request_id ] 55 | 56 | # Use a different cache store in production. 57 | # config.cache_store = :mem_cache_store 58 | 59 | # Use a real queuing backend for Active Job (and separate queues per environment). 60 | # config.active_job.queue_adapter = :resque 61 | # config.active_job.queue_name_prefix = "ROR_Facebook_Clone_production" 62 | 63 | config.action_mailer.perform_caching = false 64 | 65 | # Ignore bad email addresses and do not raise email delivery errors. 66 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 67 | # config.action_mailer.raise_delivery_errors = false 68 | 69 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 70 | # the I18n.default_locale when a translation cannot be found). 71 | config.i18n.fallbacks = true 72 | 73 | # Send deprecation notices to registered listeners. 74 | config.active_support.deprecation = :notify 75 | 76 | # Use default logging formatter so that PID and timestamp are not suppressed. 77 | config.log_formatter = ::Logger::Formatter.new 78 | 79 | # Use a different logger for distributed setups. 80 | # require 'syslog/logger' 81 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') 82 | 83 | if ENV["RAILS_LOG_TO_STDOUT"].present? 84 | logger = ActiveSupport::Logger.new(STDOUT) 85 | logger.formatter = config.log_formatter 86 | config.logger = ActiveSupport::TaggedLogging.new(logger) 87 | end 88 | 89 | # Do not dump schema after migrations. 90 | config.active_record.dump_schema_after_migration = false 91 | 92 | # Inserts middleware to perform automatic connection switching. 93 | # The `database_selector` hash is used to pass options to the DatabaseSelector 94 | # middleware. The `delay` is used to determine how long to wait after a write 95 | # to send a subsequent read to the primary. 96 | # 97 | # The `database_resolver` class is used by the middleware to determine which 98 | # database is appropriate to use based on the time delay. 99 | # 100 | # The `database_resolver_context` class is used by the middleware to set 101 | # timestamps for the last write to the primary. The resolver uses the context 102 | # class timestamps to determine how long to wait before reading from the 103 | # replica. 104 | # 105 | # By default Rails will store a last write timestamp in the session. The 106 | # DatabaseSelector middleware is designed as such you can define your own 107 | # strategy for connection switching and pass that into the middleware through 108 | # these configuration options. 109 | # config.active_record.database_selector = { delay: 2.seconds } 110 | # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver 111 | # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session 112 | end 113 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # This file was generated by the `rails generate rspec:install` command. Conventionally, all 4 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. 5 | # The generated `.rspec` file contains `--require spec_helper` which will cause 6 | # this file to always be loaded, without a need to explicitly require it in any 7 | # files. 8 | # 9 | # Given that it is always loaded, you are encouraged to keep this file as 10 | # light-weight as possible. Requiring heavyweight dependencies from this file 11 | # will add to the boot time of your test suite on EVERY test run, even for an 12 | # individual file that may not need all of that loaded. Instead, consider making 13 | # a separate helper file that requires the additional dependencies and performs 14 | # the additional setup, and require it from the spec files that actually need 15 | # it. 16 | # 17 | # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration 18 | RSpec.configure do |config| 19 | # rspec-expectations config goes here. You can use an alternate 20 | # assertion/expectation library such as wrong or the stdlib/minitest 21 | # assertions if you prefer. 22 | config.expect_with :rspec do |expectations| 23 | # This option will default to `true` in RSpec 4. It makes the `description` 24 | # and `failure_message` of custom matchers include text for helper methods 25 | # defined using `chain`, e.g.: 26 | # be_bigger_than(2).and_smaller_than(4).description 27 | # # => "be bigger than 2 and smaller than 4" 28 | # ...rather than: 29 | # # => "be bigger than 2" 30 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true 31 | end 32 | 33 | # rspec-mocks config goes here. You can use an alternate test double 34 | # library (such as bogus or mocha) by changing the `mock_with` option here. 35 | config.mock_with :rspec do |mocks| 36 | # Prevents you from mocking or stubbing a method that does not exist on 37 | # a real object. This is generally recommended, and will default to 38 | # `true` in RSpec 4. 39 | mocks.verify_partial_doubles = true 40 | end 41 | 42 | # This option will default to `:apply_to_host_groups` in RSpec 4 (and will 43 | # have no way to turn it off -- the option exists only for backwards 44 | # compatibility in RSpec 3). It causes shared context metadata to be 45 | # inherited by the metadata hash of host groups and examples, rather than 46 | # triggering implicit auto-inclusion in groups with matching metadata. 47 | config.shared_context_metadata_behavior = :apply_to_host_groups 48 | 49 | # The settings below are suggested to provide a good initial experience 50 | # with RSpec, but feel free to customize to your heart's content. 51 | 52 | # This allows you to limit a spec run to individual examples or groups 53 | # you care about by tagging them with `:focus` metadata. When nothing 54 | # is tagged with `:focus`, all examples get run. RSpec also provides 55 | # aliases for `it`, `describe`, and `context` that include `:focus` 56 | # metadata: `fit`, `fdescribe` and `fcontext`, respectively. 57 | # config.filter_run_when_matching :focus 58 | 59 | # Allows RSpec to persist some state between runs in order to support 60 | # the `--only-failures` and `--next-failure` CLI options. We recommend 61 | # you configure your source control system to ignore this file. 62 | # config.example_status_persistence_file_path = "spec/examples.txt" 63 | 64 | # Limits the available syntax to the non-monkey patched syntax that is 65 | # recommended. For more details, see: 66 | # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ 67 | # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ 68 | # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode 69 | # config.disable_monkey_patching! 70 | 71 | # Many RSpec users commonly either run the entire suite or an individual 72 | # file, and it's useful to allow more verbose output when running an 73 | # individual spec file. 74 | # if config.files_to_run.one? 75 | # Use the documentation formatter for detailed output, 76 | # unless a formatter has already been configured 77 | # (e.g. via a command-line flag). 78 | # config.default_formatter = "doc" 79 | # end 80 | 81 | # Print the 10 slowest examples and example groups at the 82 | # end of the spec run, to help surface which specs are running 83 | # particularly slow. 84 | # config.profile_examples = 10 85 | 86 | # Run specs in random order to surface order dependencies. If you find an 87 | # order dependency and want to debug it, you can fix the order by providing 88 | # the seed, which is printed after each run. 89 | # --seed 1234 90 | # config.order = :random 91 | 92 | # Seed global randomization in this process using the `--seed` CLI option. 93 | # Setting this allows you to use `--seed` to deterministically reproduce 94 | # test failures related to randomization by passing the same `--seed` value 95 | # as the one that triggered the failure. 96 | # Kernel.srand config.seed 97 | end 98 | 99 | def mock_auth_hash 100 | return unless Rails.env.test? 101 | 102 | OmniAuth.config.test_mode = true 103 | OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new( 104 | provider: 'facebook', 105 | uid: '123545', 106 | info: { 107 | first_name: 'Andrea', 108 | last_name: 'Del Rio', 109 | email: 'test@example.com' 110 | }, 111 | 112 | credentials: { 113 | token: '123456', 114 | expires_at: Time.now + 1.week 115 | } 116 | ) 117 | end 118 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actioncable (6.0.2.1) 5 | actionpack (= 6.0.2.1) 6 | nio4r (~> 2.0) 7 | websocket-driver (>= 0.6.1) 8 | actionmailbox (6.0.2.1) 9 | actionpack (= 6.0.2.1) 10 | activejob (= 6.0.2.1) 11 | activerecord (= 6.0.2.1) 12 | activestorage (= 6.0.2.1) 13 | activesupport (= 6.0.2.1) 14 | mail (>= 2.7.1) 15 | actionmailer (6.0.2.1) 16 | actionpack (= 6.0.2.1) 17 | actionview (= 6.0.2.1) 18 | activejob (= 6.0.2.1) 19 | mail (~> 2.5, >= 2.5.4) 20 | rails-dom-testing (~> 2.0) 21 | actionpack (6.0.2.1) 22 | actionview (= 6.0.2.1) 23 | activesupport (= 6.0.2.1) 24 | rack (~> 2.0, >= 2.0.8) 25 | rack-test (>= 0.6.3) 26 | rails-dom-testing (~> 2.0) 27 | rails-html-sanitizer (~> 1.0, >= 1.2.0) 28 | actiontext (6.0.2.1) 29 | actionpack (= 6.0.2.1) 30 | activerecord (= 6.0.2.1) 31 | activestorage (= 6.0.2.1) 32 | activesupport (= 6.0.2.1) 33 | nokogiri (>= 1.8.5) 34 | actionview (6.0.2.1) 35 | activesupport (= 6.0.2.1) 36 | builder (~> 3.1) 37 | erubi (~> 1.4) 38 | rails-dom-testing (~> 2.0) 39 | rails-html-sanitizer (~> 1.1, >= 1.2.0) 40 | activejob (6.0.2.1) 41 | activesupport (= 6.0.2.1) 42 | globalid (>= 0.3.6) 43 | activemodel (6.0.2.1) 44 | activesupport (= 6.0.2.1) 45 | activerecord (6.0.2.1) 46 | activemodel (= 6.0.2.1) 47 | activesupport (= 6.0.2.1) 48 | activestorage (6.0.2.1) 49 | actionpack (= 6.0.2.1) 50 | activejob (= 6.0.2.1) 51 | activerecord (= 6.0.2.1) 52 | marcel (~> 0.3.1) 53 | activesupport (6.0.2.1) 54 | concurrent-ruby (~> 1.0, >= 1.0.2) 55 | i18n (>= 0.7, < 2) 56 | minitest (~> 5.1) 57 | tzinfo (~> 1.1) 58 | zeitwerk (~> 2.2) 59 | addressable (2.7.0) 60 | public_suffix (>= 2.0.2, < 5.0) 61 | autoprefixer-rails (9.7.4) 62 | execjs 63 | bcrypt (3.1.13) 64 | bindex (0.8.1) 65 | bootsnap (1.4.6) 66 | msgpack (~> 1.0) 67 | bootstrap-sass (3.4.1) 68 | autoprefixer-rails (>= 5.2.1) 69 | sassc (>= 2.0.0) 70 | builder (3.2.4) 71 | byebug (11.1.1) 72 | capybara (3.31.0) 73 | addressable 74 | mini_mime (>= 0.1.3) 75 | nokogiri (~> 1.8) 76 | rack (>= 1.6.0) 77 | rack-test (>= 0.6.3) 78 | regexp_parser (~> 1.5) 79 | xpath (~> 3.2) 80 | childprocess (3.0.0) 81 | coderay (1.1.2) 82 | concurrent-ruby (1.1.6) 83 | crass (1.0.6) 84 | devise (4.7.1) 85 | bcrypt (~> 3.0) 86 | orm_adapter (~> 0.1) 87 | railties (>= 4.1.0) 88 | responders 89 | warden (~> 1.2.3) 90 | diff-lcs (1.3) 91 | dotenv (2.7.5) 92 | erubi (1.9.0) 93 | execjs (2.7.0) 94 | faraday (1.0.0) 95 | multipart-post (>= 1.2, < 3) 96 | ffi (1.12.2) 97 | figaro (1.1.1) 98 | thor (~> 0.14) 99 | formatador (0.2.5) 100 | globalid (0.4.2) 101 | activesupport (>= 4.2.0) 102 | guard (2.16.1) 103 | formatador (>= 0.2.4) 104 | listen (>= 2.7, < 4.0) 105 | lumberjack (>= 1.0.12, < 2.0) 106 | nenv (~> 0.1) 107 | notiffany (~> 0.0) 108 | pry (>= 0.9.12) 109 | shellany (~> 0.0) 110 | thor (>= 0.18.1) 111 | guard-compat (1.2.1) 112 | guard-rspec (4.7.3) 113 | guard (~> 2.1) 114 | guard-compat (~> 1.1) 115 | rspec (>= 2.99.0, < 4.0) 116 | hashie (4.1.0) 117 | i18n (1.8.2) 118 | concurrent-ruby (~> 1.0) 119 | jbuilder (2.9.1) 120 | activesupport (>= 4.2.0) 121 | jwt (2.2.1) 122 | listen (3.2.1) 123 | rb-fsevent (~> 0.10, >= 0.10.3) 124 | rb-inotify (~> 0.9, >= 0.9.10) 125 | loofah (2.4.0) 126 | crass (~> 1.0.2) 127 | nokogiri (>= 1.5.9) 128 | lumberjack (1.2.4) 129 | mail (2.7.1) 130 | mini_mime (>= 0.1.1) 131 | marcel (0.3.3) 132 | mimemagic (~> 0.3.2) 133 | method_source (0.9.2) 134 | mimemagic (0.3.4) 135 | mini_mime (1.0.2) 136 | mini_portile2 (2.4.0) 137 | minitest (5.14.0) 138 | msgpack (1.3.3) 139 | multi_json (1.14.1) 140 | multi_xml (0.6.0) 141 | multipart-post (2.1.1) 142 | nenv (0.3.0) 143 | nio4r (2.5.2) 144 | nokogiri (1.10.9) 145 | mini_portile2 (~> 2.4.0) 146 | notiffany (0.1.3) 147 | nenv (~> 0.1) 148 | shellany (~> 0.0) 149 | oauth2 (1.4.4) 150 | faraday (>= 0.8, < 2.0) 151 | jwt (>= 1.0, < 3.0) 152 | multi_json (~> 1.3) 153 | multi_xml (~> 0.5) 154 | rack (>= 1.2, < 3) 155 | omniauth (1.9.1) 156 | hashie (>= 3.4.6) 157 | rack (>= 1.6.2, < 3) 158 | omniauth-facebook (6.0.0) 159 | omniauth-oauth2 (~> 1.2) 160 | omniauth-oauth2 (1.6.0) 161 | oauth2 (~> 1.1) 162 | omniauth (~> 1.9) 163 | orm_adapter (0.5.0) 164 | pg (1.2.2) 165 | pry (0.12.2) 166 | coderay (~> 1.1.0) 167 | method_source (~> 0.9.0) 168 | public_suffix (4.0.3) 169 | puma (4.3.5) 170 | nio4r (~> 2.0) 171 | rack (2.2.3) 172 | rack-proxy (0.6.5) 173 | rack 174 | rack-test (1.1.0) 175 | rack (>= 1.0, < 3) 176 | rails (6.0.2.1) 177 | actioncable (= 6.0.2.1) 178 | actionmailbox (= 6.0.2.1) 179 | actionmailer (= 6.0.2.1) 180 | actionpack (= 6.0.2.1) 181 | actiontext (= 6.0.2.1) 182 | actionview (= 6.0.2.1) 183 | activejob (= 6.0.2.1) 184 | activemodel (= 6.0.2.1) 185 | activerecord (= 6.0.2.1) 186 | activestorage (= 6.0.2.1) 187 | activesupport (= 6.0.2.1) 188 | bundler (>= 1.3.0) 189 | railties (= 6.0.2.1) 190 | sprockets-rails (>= 2.0.0) 191 | rails-dom-testing (2.0.3) 192 | activesupport (>= 4.2.0) 193 | nokogiri (>= 1.6) 194 | rails-html-sanitizer (1.3.0) 195 | loofah (~> 2.3) 196 | railties (6.0.2.1) 197 | actionpack (= 6.0.2.1) 198 | activesupport (= 6.0.2.1) 199 | method_source 200 | rake (>= 0.8.7) 201 | thor (>= 0.20.3, < 2.0) 202 | rake (13.0.1) 203 | rb-fsevent (0.10.3) 204 | rb-inotify (0.10.1) 205 | ffi (~> 1.0) 206 | regexp_parser (1.7.0) 207 | responders (3.0.0) 208 | actionpack (>= 5.0) 209 | railties (>= 5.0) 210 | rspec (3.9.0) 211 | rspec-core (~> 3.9.0) 212 | rspec-expectations (~> 3.9.0) 213 | rspec-mocks (~> 3.9.0) 214 | rspec-core (3.9.1) 215 | rspec-support (~> 3.9.1) 216 | rspec-expectations (3.9.0) 217 | diff-lcs (>= 1.2.0, < 2.0) 218 | rspec-support (~> 3.9.0) 219 | rspec-mocks (3.9.1) 220 | diff-lcs (>= 1.2.0, < 2.0) 221 | rspec-support (~> 3.9.0) 222 | rspec-rails (3.9.0) 223 | actionpack (>= 3.0) 224 | activesupport (>= 3.0) 225 | railties (>= 3.0) 226 | rspec-core (~> 3.9.0) 227 | rspec-expectations (~> 3.9.0) 228 | rspec-mocks (~> 3.9.0) 229 | rspec-support (~> 3.9.0) 230 | rspec-support (3.9.2) 231 | rubyzip (2.2.0) 232 | sass-rails (6.0.0) 233 | sassc-rails (~> 2.1, >= 2.1.1) 234 | sassc (2.2.1) 235 | ffi (~> 1.9) 236 | sassc-rails (2.1.2) 237 | railties (>= 4.0.0) 238 | sassc (>= 2.0) 239 | sprockets (> 3.0) 240 | sprockets-rails 241 | tilt 242 | selenium-webdriver (3.142.7) 243 | childprocess (>= 0.5, < 4.0) 244 | rubyzip (>= 1.2.2) 245 | shellany (0.0.1) 246 | spring (2.1.0) 247 | spring-watcher-listen (2.0.1) 248 | listen (>= 2.7, < 4.0) 249 | spring (>= 1.2, < 3.0) 250 | sprockets (4.0.0) 251 | concurrent-ruby (~> 1.0) 252 | rack (> 1, < 3) 253 | sprockets-rails (3.2.1) 254 | actionpack (>= 4.0) 255 | activesupport (>= 4.0) 256 | sprockets (>= 3.0.0) 257 | thor (0.20.3) 258 | thread_safe (0.3.6) 259 | tilt (2.0.10) 260 | turbolinks (5.2.1) 261 | turbolinks-source (~> 5.2) 262 | turbolinks-source (5.2.0) 263 | tzinfo (1.2.6) 264 | thread_safe (~> 0.1) 265 | warden (1.2.8) 266 | rack (>= 2.0.6) 267 | web-console (4.0.1) 268 | actionview (>= 6.0.0) 269 | activemodel (>= 6.0.0) 270 | bindex (>= 0.4.0) 271 | railties (>= 6.0.0) 272 | webdrivers (4.2.0) 273 | nokogiri (~> 1.6) 274 | rubyzip (>= 1.3.0) 275 | selenium-webdriver (>= 3.0, < 4.0) 276 | webpacker (4.2.2) 277 | activesupport (>= 4.2) 278 | rack-proxy (>= 0.6.1) 279 | railties (>= 4.2) 280 | websocket-driver (0.7.1) 281 | websocket-extensions (>= 0.1.0) 282 | websocket-extensions (0.1.5) 283 | xpath (3.2.0) 284 | nokogiri (~> 1.8) 285 | zeitwerk (2.3.0) 286 | 287 | PLATFORMS 288 | ruby 289 | 290 | DEPENDENCIES 291 | bootsnap (>= 1.4.2) 292 | bootstrap-sass (= 3.4.1) 293 | byebug 294 | capybara (>= 2.15) 295 | devise 296 | dotenv 297 | figaro 298 | guard-rspec 299 | jbuilder (~> 2.9.1) 300 | omniauth-facebook 301 | pg (>= 0.18, < 2.0) 302 | puma (~> 4.3) 303 | rails (~> 6.0.1) 304 | rspec-rails 305 | sass-rails (>= 6) 306 | selenium-webdriver 307 | spring 308 | spring-watcher-listen (~> 2.0.0) 309 | turbolinks (~> 5) 310 | tzinfo-data 311 | web-console (>= 3.3.0) 312 | webdrivers 313 | webpacker (~> 4.0) 314 | 315 | RUBY VERSION 316 | ruby 2.6.5p114 317 | 318 | BUNDLED WITH 319 | 1.17.2 320 | -------------------------------------------------------------------------------- /config/initializers/devise.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Use this hook to configure devise mailer, warden hooks and so forth. 4 | # Many of these configuration options can be set straight in your model. 5 | Devise.setup do |config| 6 | # The secret key used by Devise. Devise uses this key to generate 7 | # random tokens. Changing this key will render invalid all existing 8 | # confirmation, reset password and unlock tokens in the database. 9 | # Devise will use the `secret_key_base` as its `secret_key` 10 | # by default. You can change it below and use your own secret key. 11 | # rubocop:disable Metrics/LineLength 12 | # config.secret_key = '58b63508dc2cb25bc15788771bb036f1a6f7221ed81c4dbd51453b301d1e719e8ebd40d4bfb13cce4e5b6d2e476087e8a03effa2d9a2b654fdbe79e411c05ce5' 13 | # rubocop:enable Metrics/LineLength 14 | # ==> Controller configuration 15 | # Configure the parent class to the devise controllers. 16 | # config.parent_controller = 'DeviseController' 17 | 18 | # ==> Mailer Configuration 19 | # Configure the e-mail address which will be shown in Devise::Mailer, 20 | # note that it will be overwritten if you use your own mailer class 21 | # with default "from" parameter. 22 | config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com' 23 | 24 | # Configure the class responsible to send e-mails. 25 | # config.mailer = 'Devise::Mailer' 26 | 27 | # Configure the parent class responsible to send e-mails. 28 | # config.parent_mailer = 'ActionMailer::Base' 29 | 30 | # ==> ORM configuration 31 | # Load and configure the ORM. Supports :active_record (default) and 32 | # :mongoid (bson_ext recommended) by default. Other ORMs may be 33 | # available as additional gems. 34 | require 'devise/orm/active_record' 35 | 36 | # ==> Configuration for any authentication mechanism 37 | # Configure which keys are used when authenticating a user. The default is 38 | # just :email. You can configure it to use [:username, :subdomain], so for 39 | # authenticating a user, both parameters are required. Remember that those 40 | # parameters are used only when authenticating and not when retrieving from 41 | # session. If you need permissions, you should implement that in a before filter. 42 | # You can also supply a hash where the value is a boolean determining whether 43 | # or not authentication should be aborted when the value is not present. 44 | # config.authentication_keys = [:email] 45 | 46 | # Configure parameters from the request object used for authentication. Each entry 47 | # given should be a request method and it will automatically be passed to the 48 | # find_for_authentication method and considered in your model lookup. For instance, 49 | # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. 50 | # The same considerations mentioned for authentication_keys also apply to request_keys. 51 | # config.request_keys = [] 52 | 53 | # Configure which authentication keys should be case-insensitive. 54 | # These keys will be downcased upon creating or modifying a user and when used 55 | # to authenticate or find a user. Default is :email. 56 | config.case_insensitive_keys = [:email] 57 | 58 | # Configure which authentication keys should have whitespace stripped. 59 | # These keys will have whitespace before and after removed upon creating or 60 | # modifying a user and when used to authenticate or find a user. Default is :email. 61 | config.strip_whitespace_keys = [:email] 62 | 63 | # Tell if authentication through request.params is enabled. True by default. 64 | # It can be set to an array that will enable params authentication only for the 65 | # given strategies, for example, `config.params_authenticatable = [:database]` will 66 | # enable it only for database (email + password) authentication. 67 | # config.params_authenticatable = true 68 | 69 | # Tell if authentication through HTTP Auth is enabled. False by default. 70 | # It can be set to an array that will enable http authentication only for the 71 | # given strategies, for example, `config.http_authenticatable = [:database]` will 72 | # enable it only for database authentication. The supported strategies are: 73 | # :database = Support basic authentication with authentication key + password 74 | # config.http_authenticatable = false 75 | 76 | # If 401 status code should be returned for AJAX requests. True by default. 77 | # config.http_authenticatable_on_xhr = true 78 | 79 | # The realm used in Http Basic Authentication. 'Application' by default. 80 | # config.http_authentication_realm = 'Application' 81 | 82 | # It will change confirmation, password recovery and other workflows 83 | # to behave the same regardless if the e-mail provided was right or wrong. 84 | # Does not affect registerable. 85 | # config.paranoid = true 86 | 87 | # By default Devise will store the user in session. You can skip storage for 88 | # particular strategies by setting this option. 89 | # Notice that if you are skipping storage for all authentication paths, you 90 | # may want to disable generating routes to Devise's sessions controller by 91 | # passing skip: :sessions to `devise_for` in your config/routes.rb 92 | config.skip_session_storage = [:http_auth] 93 | 94 | # By default, Devise cleans up the CSRF token on authentication to 95 | # avoid CSRF token fixation attacks. This means that, when using AJAX 96 | # requests for sign in and sign up, you need to get a new CSRF token 97 | # from the server. You can disable this option at your own risk. 98 | # config.clean_up_csrf_token_on_authentication = true 99 | 100 | # When false, Devise will not attempt to reload routes on eager load. 101 | # This can reduce the time taken to boot the app but if your application 102 | # requires the Devise mappings to be loaded during boot time the application 103 | # won't boot properly. 104 | # config.reload_routes = true 105 | 106 | # ==> Configuration for :database_authenticatable 107 | # For bcrypt, this is the cost for hashing the password and defaults to 11. If 108 | # using other algorithms, it sets how many times you want the password to be hashed. 109 | # 110 | # Limiting the stretches to just one in testing will increase the performance of 111 | # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use 112 | # a value less than 10 in other environments. Note that, for bcrypt (the default 113 | # algorithm), the cost increases exponentially with the number of stretches (e.g. 114 | # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation). 115 | config.stretches = Rails.env.test? ? 1 : 11 116 | 117 | # Set up a pepper to generate the hashed password. 118 | # rubocop: disable Metrics/LineLength 119 | # config.pepper = '639416b54f756185e502fa0de8eb38d72108a158a2033af84e6ba197aa69b4ad3e5267580ea1d42e83fb706c6ae66e6fb35a3557af0a9086abe4a4cef921e255' 120 | # rubocop: enable Metrics/LineLength 121 | # Send a notification to the original email when the user's email is changed. 122 | # config.send_email_changed_notification = false 123 | 124 | # Send a notification email when the user's password is changed. 125 | # config.send_password_change_notification = false 126 | 127 | # ==> Configuration for :confirmable 128 | # A period that the user is allowed to access the website even without 129 | # confirming their account. For instance, if set to 2.days, the user will be 130 | # able to access the website for two days without confirming their account, 131 | # access will be blocked just in the third day. 132 | # You can also set it to nil, which will allow the user to access the website 133 | # without confirming their account. 134 | # Default is 0.days, meaning the user cannot access the website without 135 | # confirming their account. 136 | # config.allow_unconfirmed_access_for = 2.days 137 | 138 | # A period that the user is allowed to confirm their account before their 139 | # token becomes invalid. For example, if set to 3.days, the user can confirm 140 | # their account within 3 days after the mail was sent, but on the fourth day 141 | # their account can't be confirmed with the token any more. 142 | # Default is nil, meaning there is no restriction on how long a user can take 143 | # before confirming their account. 144 | # config.confirm_within = 3.days 145 | 146 | # If true, requires any email changes to be confirmed (exactly the same way as 147 | # initial account confirmation) to be applied. Requires additional unconfirmed_email 148 | # db field (see migrations). Until confirmed, new email is stored in 149 | # unconfirmed_email column, and copied to email column on successful confirmation. 150 | config.reconfirmable = true 151 | 152 | # Defines which key will be used when confirming an account 153 | # config.confirmation_keys = [:email] 154 | 155 | # ==> Configuration for :rememberable 156 | # The time the user will be remembered without asking for credentials again. 157 | # config.remember_for = 2.weeks 158 | 159 | # Invalidates all the remember me tokens when the user signs out. 160 | config.expire_all_remember_me_on_sign_out = true 161 | 162 | # If true, extends the user's remember period when remembered via cookie. 163 | # config.extend_remember_period = false 164 | 165 | # Options to be passed to the created cookie. For instance, you can set 166 | # secure: true in order to force SSL only cookies. 167 | # config.rememberable_options = {} 168 | 169 | # ==> Configuration for :validatable 170 | # Range for password length. 171 | config.password_length = 6..128 172 | 173 | # Email regex used to validate email formats. It simply asserts that 174 | # one (and only one) @ exists in the given string. This is mainly 175 | # to give user feedback and not to assert the e-mail validity. 176 | config.email_regexp = /\A[^@\s]+@[^@\s]+\z/ 177 | 178 | # ==> Configuration for :timeoutable 179 | # The time you want to timeout the user session without activity. After this 180 | # time the user will be asked for credentials again. Default is 30 minutes. 181 | # config.timeout_in = 30.minutes 182 | 183 | # ==> Configuration for :lockable 184 | # Defines which strategy will be used to lock an account. 185 | # :failed_attempts = Locks an account after a number of failed attempts to sign in. 186 | # :none = No lock strategy. You should handle locking by yourself. 187 | # config.lock_strategy = :failed_attempts 188 | 189 | # Defines which key will be used when locking and unlocking an account 190 | # config.unlock_keys = [:email] 191 | 192 | # Defines which strategy will be used to unlock an account. 193 | # :email = Sends an unlock link to the user email 194 | # :time = Re-enables login after a certain amount of time (see :unlock_in below) 195 | # :both = Enables both strategies 196 | # :none = No unlock strategy. You should handle unlocking by yourself. 197 | # config.unlock_strategy = :both 198 | 199 | # Number of authentication tries before locking an account if lock_strategy 200 | # is failed attempts. 201 | # config.maximum_attempts = 20 202 | 203 | # Time interval to unlock the account if :time is enabled as unlock_strategy. 204 | # config.unlock_in = 1.hour 205 | 206 | # Warn on the last attempt before the account is locked. 207 | # config.last_attempt_warning = true 208 | 209 | # ==> Configuration for :recoverable 210 | # 211 | # Defines which key will be used when recovering the password for an account 212 | # config.reset_password_keys = [:email] 213 | 214 | # Time interval you can reset your password with a reset password key. 215 | # Don't put a too small interval or your users won't have the time to 216 | # change their passwords. 217 | config.reset_password_within = 6.hours 218 | 219 | # When set to false, does not sign a user in automatically after their password is 220 | # reset. Defaults to true, so a user is signed in automatically after a reset. 221 | # config.sign_in_after_reset_password = true 222 | 223 | # ==> Configuration for :encryptable 224 | # Allow you to use another hashing or encryption algorithm besides bcrypt (default). 225 | # You can use :sha1, :sha512 or algorithms from others authentication tools as 226 | # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20 227 | # for default behavior) and :restful_authentication_sha1 (then you should set 228 | # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper). 229 | # 230 | # Require the `devise-encryptable` gem when using anything other than bcrypt 231 | # config.encryptor = :sha512 232 | 233 | # ==> Scopes configuration 234 | # Turn scoped views on. Before rendering "sessions/new", it will first check for 235 | # "users/sessions/new". It's turned off by default because it's slower if you 236 | # are using only default views. 237 | config.scoped_views = true 238 | 239 | # Configure the default scope given to Warden. By default it's the first 240 | # devise role declared in your routes (usually :user). 241 | # config.default_scope = :user 242 | 243 | # Set this configuration to false if you want /users/sign_out to sign out 244 | # only the current scope. By default, Devise signs out all scopes. 245 | # config.sign_out_all_scopes = true 246 | 247 | # ==> Navigation configuration 248 | # Lists the formats that should be treated as navigational. Formats like 249 | # :html, should redirect to the sign in page when the user does not have 250 | # access, but formats like :xml or :json, should return 401. 251 | # 252 | # If you have any extra navigational formats, like :iphone or :mobile, you 253 | # should add them to the navigational formats lists. 254 | # 255 | # The "*/*" below is required to match Internet Explorer requests. 256 | # config.navigational_formats = ['*/*', :html] 257 | 258 | # The default HTTP method used to sign out a resource. Default is :delete. 259 | config.sign_out_via = :delete 260 | 261 | # ==> OmniAuth 262 | # Add a new OmniAuth provider. Check the wiki for more information on setting 263 | # up on your models and hooks. 264 | # ==> Warden configuration 265 | # If you want to use other strategies, that are not supported by Devise, or 266 | # change the failure app, you can configure them inside the config.warden block. 267 | # 268 | # config.warden do |manager| 269 | # manager.intercept_401 = false 270 | # manager.default_strategies(scope: :user).unshift :some_external_strategy 271 | # end 272 | 273 | # ==> Mountable engine configurations 274 | # When using Devise inside an engine, let's call it `MyEngine`, and this engine 275 | # is mountable, there are some extra configurations to be taken into account. 276 | # The following options are available, assuming the engine is mounted as: 277 | # 278 | # mount MyEngine, at: '/my_engine' 279 | # 280 | # The router that invoked `devise_for`, in the example above, would be: 281 | # config.router_name = :my_engine 282 | # 283 | # When using OmniAuth, Devise cannot automatically set OmniAuth path, 284 | # so you need to do it manually. For the users scope, it would be: 285 | # config.omniauth_path_prefix = '/my_engine/users/auth' 286 | config.omniauth :facebook, ENV['FACEBOOK_KEY'], ENV['FACEBOOK_SECRET'] 287 | 288 | # ==> Turbolinks configuration 289 | # If your app is using Turbolinks, Turbolinks::Controller needs to be included to make redirection work correctly: 290 | # 291 | # ActiveSupport.on_load(:devise_failure_app) do 292 | # include Turbolinks::Controller 293 | # end 294 | 295 | # ==> Configuration for :registerable 296 | 297 | # When set to false, does not sign a user in automatically after their password is 298 | # changed. Defaults to true, so a user is signed in automatically after changing a password. 299 | # config.sign_in_after_change_password = true 300 | end 301 | --------------------------------------------------------------------------------