├── log └── .keep ├── tmp └── .keep ├── vendor └── .keep ├── lib ├── assets │ └── .keep ├── tasks │ └── .keep └── templates │ └── erb │ └── scaffold │ └── _form.html.erb ├── 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 │ ├── user_test.rb │ └── tweeet_test.rb ├── system │ ├── .keep │ └── tweeets_test.rb ├── controllers │ ├── .keep │ └── tweeets_controller_test.rb ├── fixtures │ ├── .keep │ ├── files │ │ └── .keep │ ├── tweeets.yml │ └── users.yml ├── integration │ └── .keep ├── application_system_test_case.rb └── test_helper.rb ├── app ├── assets │ ├── images │ │ └── .keep │ ├── javascripts │ │ ├── channels │ │ │ └── .keep │ │ ├── tweeets.coffee │ │ ├── cable.js │ │ └── application.js │ ├── config │ │ └── manifest.js │ └── stylesheets │ │ ├── tweeets.scss │ │ └── application.scss ├── models │ ├── concerns │ │ └── .keep │ ├── tweeet.rb │ ├── application_record.rb │ └── user.rb ├── controllers │ ├── concerns │ │ └── .keep │ ├── application_controller.rb │ ├── registrations_controller.rb │ └── tweeets_controller.rb ├── views │ ├── layouts │ │ ├── mailer.text.erb │ │ ├── mailer.html.erb │ │ └── application.html.erb │ ├── tweeets │ │ ├── show.json.jbuilder │ │ ├── index.json.jbuilder │ │ ├── _tweeet.json.jbuilder │ │ ├── show.html.erb │ │ ├── index.html.erb │ │ ├── _form.html.erb │ │ ├── _trends.html.erb │ │ ├── edit.html.erb │ │ ├── new.html.erb │ │ ├── _profile.html.erb │ │ ├── _who-to-follow.html.erb │ │ └── _feed.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 │ │ ├── unlocks │ │ └── new.html.erb │ │ ├── confirmations │ │ └── new.html.erb │ │ ├── passwords │ │ ├── new.html.erb │ │ └── edit.html.erb │ │ ├── sessions │ │ └── new.html.erb │ │ ├── shared │ │ └── _links.html.erb │ │ └── registrations │ │ ├── new.html.erb │ │ └── edit.html.erb ├── helpers │ ├── tweeets_helper.rb │ └── application_helper.rb ├── jobs │ └── application_job.rb ├── channels │ └── application_cable │ │ ├── channel.rb │ │ └── connection.rb └── mailers │ └── application_mailer.rb ├── package.json ├── bin ├── bundle ├── rake ├── rails ├── yarn ├── spring ├── update └── setup ├── config ├── spring.rb ├── boot.rb ├── environment.rb ├── initializers │ ├── mime_types.rb │ ├── filter_parameter_logging.rb │ ├── application_controller_renderer.rb │ ├── cookies_serializer.rb │ ├── backtrace_silencers.rb │ ├── wrap_parameters.rb │ ├── assets.rb │ ├── inflections.rb │ ├── simple_form.rb │ └── devise.rb ├── cable.yml ├── routes.rb ├── application.rb ├── database.yml ├── locales │ ├── simple_form.en.yml │ ├── en.yml │ └── devise.en.yml ├── secrets.yml ├── environments │ ├── test.rb │ ├── development.rb │ └── production.rb └── puma.rb ├── config.ru ├── db ├── migrate │ ├── 20171130000452_add_user_id_to_tweeets.rb │ ├── 20171129222907_create_tweeets.rb │ ├── 20171129234833_add_fields_to_users.rb │ └── 20171129234035_devise_create_users.rb ├── seeds.rb └── schema.rb ├── Rakefile ├── .gitignore ├── Guardfile ├── Gemfile ├── README.md └── Gemfile.lock /log/.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 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/controllers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/fixtures/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/integration/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/apple-touch-icon.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/fixtures/files/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/assets/javascripts/channels/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/apple-touch-icon-precomposed.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.text.erb: -------------------------------------------------------------------------------- 1 | <%= yield %> 2 | -------------------------------------------------------------------------------- /app/helpers/tweeets_helper.rb: -------------------------------------------------------------------------------- 1 | module TweeetsHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | end 3 | -------------------------------------------------------------------------------- /app/models/tweeet.rb: -------------------------------------------------------------------------------- 1 | class Tweeet < ApplicationRecord 2 | belongs_to :user 3 | end 4 | -------------------------------------------------------------------------------- /app/views/tweeets/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.partial! "tweeets/tweeet", tweeet: @tweeet 2 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "twittter", 3 | "private": true, 4 | "dependencies": {} 5 | } 6 | -------------------------------------------------------------------------------- /app/views/tweeets/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.array! @tweeets, partial: 'tweeets/tweeet', as: :tweeet 2 | -------------------------------------------------------------------------------- /app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | self.abstract_class = true 3 | end 4 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | -------------------------------------------------------------------------------- /app/channels/application_cable/channel.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Channel < ActionCable::Channel::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/assets/config/manifest.js: -------------------------------------------------------------------------------- 1 | //= link_tree ../images 2 | //= link_directory ../javascripts .js 3 | //= link_directory ../stylesheets .css 4 | -------------------------------------------------------------------------------- /app/channels/application_cable/connection.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Connection < ActionCable::Connection::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | protect_from_forgery with: :exception 3 | end 4 | -------------------------------------------------------------------------------- /app/mailers/application_mailer.rb: -------------------------------------------------------------------------------- 1 | class ApplicationMailer < ActionMailer::Base 2 | default from: 'from@example.com' 3 | layout 'mailer' 4 | end 5 | -------------------------------------------------------------------------------- /app/views/tweeets/_tweeet.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.extract! tweeet, :id, :tweeet, :created_at, :updated_at 2 | json.url tweeet_url(tweeet, format: :json) 3 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /config/spring.rb: -------------------------------------------------------------------------------- 1 | %w( 2 | .ruby-version 3 | .rbenv-vars 4 | tmp/restart.txt 5 | tmp/caching-dev.txt 6 | ).each { |path| Spring.watch(path) } 7 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require_relative 'config/environment' 4 | 5 | run Rails.application 6 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require_relative 'application' 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /test/models/user_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class UserTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /app/views/devise/mailer/password_change.html.erb: -------------------------------------------------------------------------------- 1 |

Hello <%= @resource.email %>!

2 | 3 |

We're contacting you to notify you that your password has been changed.

4 | -------------------------------------------------------------------------------- /test/models/tweeet_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TweeetTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /test/fixtures/tweeets.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 2 | 3 | one: 4 | tweeet: MyText 5 | 6 | two: 7 | tweeet: MyText 8 | -------------------------------------------------------------------------------- /db/migrate/20171130000452_add_user_id_to_tweeets.rb: -------------------------------------------------------------------------------- 1 | class AddUserIdToTweeets < ActiveRecord::Migration[5.1] 2 | def change 3 | add_column :tweeets, :user_id, :integer 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /test/application_system_test_case.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | 3 | class ApplicationSystemTestCase < ActionDispatch::SystemTestCase 4 | driven_by :selenium, using: :chrome, screen_size: [1400, 1400] 5 | end 6 | -------------------------------------------------------------------------------- /config/cable.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: async 3 | 4 | test: 5 | adapter: async 6 | 7 | production: 8 | adapter: redis 9 | url: redis://localhost:6379/1 10 | channel_prefix: twittter_production 11 | -------------------------------------------------------------------------------- /app/assets/stylesheets/tweeets.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the Tweeets controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | -------------------------------------------------------------------------------- /db/migrate/20171129222907_create_tweeets.rb: -------------------------------------------------------------------------------- 1 | class CreateTweeets < ActiveRecord::Migration[5.1] 2 | def change 3 | create_table :tweeets do |t| 4 | t.text :tweeet 5 | 6 | t.timestamps 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require_relative 'config/application' 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /app/assets/javascripts/tweeets.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://coffeescript.org/ 4 | -------------------------------------------------------------------------------- /app/views/tweeets/show.html.erb: -------------------------------------------------------------------------------- 1 |

<%= notice %>

2 | 3 |

4 | Tweeet: 5 | <%= @tweeet.tweeet %> 6 |

7 | 8 | <%= link_to 'Edit', edit_tweeet_path(@tweeet) %> | 9 | <%= link_to 'Back', tweeets_path %> 10 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 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 | require_relative '../config/boot' 8 | require 'rake' 9 | Rake.application.run 10 | -------------------------------------------------------------------------------- /app/views/devise/mailer/confirmation_instructions.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 | -------------------------------------------------------------------------------- /db/migrate/20171129234833_add_fields_to_users.rb: -------------------------------------------------------------------------------- 1 | class AddFieldsToUsers < ActiveRecord::Migration[5.1] 2 | def change 3 | add_column :users, :name, :string 4 | add_column :users, :username, :string 5 | add_index :users, :username, unique: true 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/system/tweeets_test.rb: -------------------------------------------------------------------------------- 1 | require "application_system_test_case" 2 | 3 | class TweeetsTest < ApplicationSystemTestCase 4 | # test "visiting the index" do 5 | # visit tweeets_url 6 | # 7 | # assert_selector "h1", text: "Tweeet" 8 | # end 9 | end 10 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | devise_for :users, :controllers => { registrations: 'registrations' } 3 | resources :tweeets 4 | # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html 5 | root "tweeets#index" 6 | end 7 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/models/user.rb: -------------------------------------------------------------------------------- 1 | class User < ApplicationRecord 2 | # Include default devise modules. Others available are: 3 | # :confirmable, :lockable, :timeoutable and :omniauthable 4 | devise :database_authenticatable, :registerable, 5 | :recoverable, :rememberable, :trackable, :validatable 6 | 7 | has_many :tweeets 8 | end 9 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../config/environment', __FILE__) 2 | require 'rails/test_help' 3 | 4 | class ActiveSupport::TestCase 5 | # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. 6 | fixtures :all 7 | 8 | # Add more helper methods to be used by all tests here... 9 | end 10 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /bin/yarn: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | VENDOR_PATH = File.expand_path('..', __dir__) 3 | Dir.chdir(VENDOR_PATH) do 4 | begin 5 | exec "yarnpkg #{ARGV.join(" ")}" 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 | -------------------------------------------------------------------------------- /app/views/tweeets/index.html.erb: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | <% if user_signed_in? %> 5 | <%= render 'profile' %> 6 | <% else %> 7 | <%= render 'trends' %> 8 | <% end %> 9 | 10 | <%= render 'feed' %> 11 | <%= render 'who-to-follow' %> 12 |
13 |
14 |
15 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/fixtures/users.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://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 | -------------------------------------------------------------------------------- /app/views/tweeets/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= simple_form_for(@tweeet) do |f| %> 2 | <%= f.error_notification %> 3 |
4 |
5 | <%= f.input :tweeet, label: "Tweeet about it", input_html: { class: "textarea "}, wrapper: false, label_html: {class: "label"}, placeholder: "Compose a new tweeet...", autofocus: true %> 6 |
7 |
8 | <%= f.button :submit, class: "button is-info" %> 9 | <% end %> -------------------------------------------------------------------------------- /app/controllers/registrations_controller.rb: -------------------------------------------------------------------------------- 1 | class RegistrationsController < Devise::RegistrationsController 2 | 3 | private 4 | 5 | def sign_up_params 6 | params.require(:user).permit(:name, :username, :email, :password, :password_confirmation) 7 | end 8 | 9 | def acount_update_params 10 | params.require(:user).permit(:name, :username, :email, :password, :password_confirmation, :current_password) 11 | end 12 | 13 | end 14 | -------------------------------------------------------------------------------- /app/assets/javascripts/cable.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 | //= require action_cable 5 | //= require_self 6 | //= require_tree ./channels 7 | 8 | (function() { 9 | this.App || (this.App = {}); 10 | 11 | App.cable = ActionCable.createConsumer(); 12 | 13 | }).call(this); 14 | -------------------------------------------------------------------------------- /lib/templates/erb/scaffold/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%%= simple_form_for(@<%= singular_table_name %>) do |f| %> 2 | <%%= f.error_notification %> 3 | 4 |
5 | <%- attributes.each do |attribute| -%> 6 | <%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %> 7 | <%- end -%> 8 |
9 | 10 |
11 | <%%= f.button :submit %> 12 |
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 | -------------------------------------------------------------------------------- /app/views/tweeets/_trends.html.erb: -------------------------------------------------------------------------------- 1 |
2 | 23 |
-------------------------------------------------------------------------------- /app/views/devise/unlocks/new.html.erb: -------------------------------------------------------------------------------- 1 |

Resend unlock instructions

2 | 3 | <%= simple_form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %> 4 | <%= f.error_notification %> 5 | <%= f.full_error :unlock_token %> 6 | 7 |
8 | <%= f.input :email, required: true, autofocus: true %> 9 |
10 | 11 |
12 | <%= f.button :submit, "Resend unlock instructions" %> 13 |
14 | <% end %> 15 | 16 | <%= render "devise/shared/links" %> 17 | -------------------------------------------------------------------------------- /config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # This file contains settings for ActionController::ParamsWrapper which 4 | # is enabled by default. 5 | 6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 7 | ActiveSupport.on_load(:action_controller) do 8 | wrap_parameters format: [:json] 9 | end 10 | 11 | # To enable root element in JSON for ActiveRecord objects. 12 | # ActiveSupport.on_load(:active_record) do 13 | # self.include_root_in_json = true 14 | # end 15 | -------------------------------------------------------------------------------- /bin/spring: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # This file loads spring without using Bundler, in order to be fast. 4 | # It gets overwritten when you run the `spring binstub` command. 5 | 6 | unless defined?(Spring) 7 | require 'rubygems' 8 | require 'bundler' 9 | 10 | lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) 11 | spring = lockfile.specs.detect { |spec| spec.name == "spring" } 12 | if spring 13 | Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path 14 | gem 'spring', spring.version 15 | require 'spring/binstub' 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /app/views/devise/confirmations/new.html.erb: -------------------------------------------------------------------------------- 1 |

Resend confirmation instructions

2 | 3 | <%= simple_form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %> 4 | <%= f.error_notification %> 5 | <%= f.full_error :confirmation_token %> 6 | 7 |
8 | <%= f.input :email, required: true, autofocus: true %> 9 |
10 | 11 |
12 | <%= f.button :submit, "Resend confirmation instructions" %> 13 |
14 | <% end %> 15 | 16 | <%= render "devise/shared/links" %> 17 | -------------------------------------------------------------------------------- /app/views/tweeets/edit.html.erb: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |

Editing Tweeet

6 | <%= render 'form', tweeet: @tweeet %> 7 |
8 |
9 |
10 |
11 | 12 | 22 | -------------------------------------------------------------------------------- /app/views/tweeets/new.html.erb: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |

Create a new Tweeet

6 | <%= render 'form', tweeet: @tweeet %> 7 |
8 |
9 |
10 |
11 | 12 | 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore the default SQLite database. 11 | /db/*.sqlite3 12 | /db/*.sqlite3-journal 13 | 14 | # Ignore all logfiles and tempfiles. 15 | /log/* 16 | /tmp/* 17 | !/log/.keep 18 | !/tmp/.keep 19 | 20 | /node_modules 21 | /yarn-error.log 22 | 23 | .byebug_history 24 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require_relative 'boot' 2 | 3 | require 'rails/all' 4 | 5 | # Require the gems listed in Gemfile, including any gems 6 | # you've limited to :test, :development, or :production. 7 | Bundler.require(*Rails.groups) 8 | 9 | module Twittter 10 | class Application < Rails::Application 11 | # Initialize configuration defaults for originally generated Rails version. 12 | config.load_defaults 5.1 13 | 14 | # Settings in config/environments/* take precedence over those specified here. 15 | # Application configuration should go into files in config/initializers 16 | # -- all .rb files in that directory are automatically loaded. 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /config/initializers/assets.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Version of your assets, change this if you want to expire all your assets. 4 | Rails.application.config.assets.version = '1.0' 5 | 6 | # Add additional assets to the asset load path. 7 | # Rails.application.config.assets.paths << Emoji.images_path 8 | # Add Yarn node_modules folder to the asset load path. 9 | Rails.application.config.assets.paths << Rails.root.join('node_modules') 10 | 11 | # Precompile additional assets. 12 | # application.js, application.css, and all non-JS/CSS in the app/assets 13 | # folder are already added. 14 | # Rails.application.config.assets.precompile += %w( admin.js admin.css ) 15 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite version 3.x 2 | # gem install sqlite3 3 | # 4 | # Ensure the SQLite 3 gem is defined in your Gemfile 5 | # gem 'sqlite3' 6 | # 7 | default: &default 8 | adapter: sqlite3 9 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 10 | timeout: 5000 11 | 12 | development: 13 | <<: *default 14 | database: db/development.sqlite3 15 | 16 | # Warning: The database defined as "test" will be erased and 17 | # re-generated from your development database when you run "rake". 18 | # Do not set this db to the same as development or production. 19 | test: 20 | <<: *default 21 | database: db/test.sqlite3 22 | 23 | production: 24 | <<: *default 25 | database: db/production.sqlite3 26 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, '\1en' 8 | # inflect.singular /^(ox)en/i, '\1' 9 | # inflect.irregular 'person', 'people' 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym 'RESTful' 16 | # end 17 | -------------------------------------------------------------------------------- /app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into application.js, which will include all the files 2 | // listed below. 3 | // 4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's 5 | // vendor/assets/javascripts directory can be referenced here using a relative path. 6 | // 7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 8 | // compiled file. JavaScript code in this file should be added after the last require_* statement. 9 | // 10 | // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 11 | // about supported directives. 12 | // 13 | //= require rails-ujs 14 | //= require turbolinks 15 | //= require_tree . 16 | -------------------------------------------------------------------------------- /bin/update: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'pathname' 3 | require 'fileutils' 4 | include FileUtils 5 | 6 | # path to your application root. 7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) 8 | 9 | def system!(*args) 10 | system(*args) || abort("\n== Command #{args} failed ==") 11 | end 12 | 13 | chdir APP_ROOT do 14 | # This script is a way to update your development environment automatically. 15 | # Add necessary update steps to this file. 16 | 17 | puts '== Installing dependencies ==' 18 | system! 'gem install bundler --conservative' 19 | system('bundle check') || system!('bundle install') 20 | 21 | puts "\n== Updating database ==" 22 | system! 'bin/rails db:migrate' 23 | 24 | puts "\n== Removing old logs and tempfiles ==" 25 | system! 'bin/rails log:clear tmp:clear' 26 | 27 | puts "\n== Restarting application server ==" 28 | system! 'bin/rails restart' 29 | end 30 | -------------------------------------------------------------------------------- /app/views/devise/passwords/new.html.erb: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 | 6 |

Forgot your password?

7 | 8 | <%= simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %> 9 | <%= f.error_notification %> 10 | 11 |
12 |
13 | <%= f.input :email, required: true, autofocus: true, input_html: { class: "input"}, wrapper: false, label_html: { class: "label" } %> 14 |
15 |
16 | 17 | <%= f.button :submit, "Send me reset password instructions", class:"button is-info" %> 18 | 19 | <% end %> 20 |
21 | <%= render "devise/shared/links" %> 22 | 23 |
24 |
25 |
26 |
-------------------------------------------------------------------------------- /config/locales/simple_form.en.yml: -------------------------------------------------------------------------------- 1 | en: 2 | simple_form: 3 | "yes": 'Yes' 4 | "no": 'No' 5 | required: 6 | text: 'required' 7 | mark: '*' 8 | # You can uncomment the line below if you need to overwrite the whole required html. 9 | # When using html, text and mark won't be used. 10 | # html: '*' 11 | error_notification: 12 | default_message: "Please review the problems below:" 13 | # Examples 14 | # labels: 15 | # defaults: 16 | # password: 'Password' 17 | # user: 18 | # new: 19 | # email: 'E-mail to sign in.' 20 | # edit: 21 | # email: 'E-mail.' 22 | # hints: 23 | # defaults: 24 | # username: 'User name to sign in.' 25 | # password: 'No special characters, please.' 26 | # include_blanks: 27 | # defaults: 28 | # age: 'Rather not say' 29 | # prompts: 30 | # defaults: 31 | # age: 'Select your age' 32 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t 'hello' 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t('hello') %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # The following keys must be escaped otherwise they will not be retrieved by 20 | # the default I18n backend: 21 | # 22 | # true, false, on, off, yes, no 23 | # 24 | # Instead, surround them with single quotes. 25 | # 26 | # en: 27 | # 'true': 'foo' 28 | # 29 | # To learn more, please read the Rails Internationalization guide 30 | # available at http://guides.rubyonrails.org/i18n.html. 31 | 32 | en: 33 | hello: "Hello world" 34 | -------------------------------------------------------------------------------- /app/assets/stylesheets/application.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's 6 | * vendor/assets/stylesheets directory can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the 9 | * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS 10 | * files in this directory. Styles in this file should be added after the last require_* statement. 11 | * It is generally better to create a new file per style scope. 12 | * 13 | *= require_tree . 14 | *= require_self 15 | */ 16 | 17 | @import "bulma"; 18 | 19 | .navbar-brand .title { 20 | color: white; 21 | } 22 | 23 | // round images 24 | .image { 25 | border-radius: 50%; 26 | img { 27 | border-radius: 50%; 28 | } 29 | } 30 | .notification:not(:last-child) { 31 | margin-bottom: 0; 32 | } 33 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'pathname' 3 | require 'fileutils' 4 | include FileUtils 5 | 6 | # path to your application root. 7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) 8 | 9 | def system!(*args) 10 | system(*args) || abort("\n== Command #{args} failed ==") 11 | end 12 | 13 | chdir APP_ROOT do 14 | # This script is a starting point to setup your application. 15 | # Add necessary setup steps to this file. 16 | 17 | puts '== Installing dependencies ==' 18 | system! 'gem install bundler --conservative' 19 | system('bundle check') || system!('bundle install') 20 | 21 | # Install JavaScript dependencies if using Yarn 22 | # system('bin/yarn') 23 | 24 | 25 | # puts "\n== Copying sample files ==" 26 | # unless File.exist?('config/database.yml') 27 | # cp 'config/database.yml.sample', 'config/database.yml' 28 | # end 29 | 30 | puts "\n== Preparing database ==" 31 | system! 'bin/rails db:setup' 32 | 33 | puts "\n== Removing old logs and tempfiles ==" 34 | system! 'bin/rails log:clear tmp:clear' 35 | 36 | puts "\n== Restarting application server ==" 37 | system! 'bin/rails restart' 38 | end 39 | -------------------------------------------------------------------------------- /app/views/devise/sessions/new.html.erb: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |

Log in

6 | <%= simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> 7 | 8 |
9 |
10 | <%= f.input :email, required: false, input_html: { class: "input"}, wrapper: false, label_html: { class: "label" } %> 11 |
12 |
13 | 14 |
15 |
16 | <%= f.input :password, required: false, input_html: { class: "input"}, wrapper: false, label_html: { class: "label" } %> 17 |
18 |
19 | 20 |
21 |
22 | <%= f.input :remember_me, wrapper: false, as: :boolean if devise_mapping.rememberable? %> 23 |
24 |
25 | 26 | <%= f.button :submit, "Log in", class:"button is-info is-medium" %> 27 | <% end %> 28 |
29 | <%= render "devise/shared/links" %> 30 |
31 |
32 |
33 |
-------------------------------------------------------------------------------- /app/views/devise/shared/_links.html.erb: -------------------------------------------------------------------------------- 1 | <%- if controller_name != 'sessions' %> 2 | <%= link_to "Log in", new_session_path(resource_name) %>
3 | <% end -%> 4 | 5 | <%- if devise_mapping.registerable? && controller_name != 'registrations' %> 6 | <%= link_to "Sign up", new_registration_path(resource_name) %>
7 | <% end -%> 8 | 9 | <%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %> 10 | <%= link_to "Forgot your password?", new_password_path(resource_name) %>
11 | <% end -%> 12 | 13 | <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> 14 | <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %>
15 | <% end -%> 16 | 17 | <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %> 18 | <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %>
19 | <% end -%> 20 | 21 | <%- if devise_mapping.omniauthable? %> 22 | <%- resource_class.omniauth_providers.each do |provider| %> 23 | <%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider) %>
24 | <% end -%> 25 | <% end -%> 26 | -------------------------------------------------------------------------------- /test/controllers/tweeets_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class TweeetsControllerTest < ActionDispatch::IntegrationTest 4 | setup do 5 | @tweeet = tweeets(:one) 6 | end 7 | 8 | test "should get index" do 9 | get tweeets_url 10 | assert_response :success 11 | end 12 | 13 | test "should get new" do 14 | get new_tweeet_url 15 | assert_response :success 16 | end 17 | 18 | test "should create tweeet" do 19 | assert_difference('Tweeet.count') do 20 | post tweeets_url, params: { tweeet: { tweeet: @tweeet.tweeet } } 21 | end 22 | 23 | assert_redirected_to tweeet_url(Tweeet.last) 24 | end 25 | 26 | test "should show tweeet" do 27 | get tweeet_url(@tweeet) 28 | assert_response :success 29 | end 30 | 31 | test "should get edit" do 32 | get edit_tweeet_url(@tweeet) 33 | assert_response :success 34 | end 35 | 36 | test "should update tweeet" do 37 | patch tweeet_url(@tweeet), params: { tweeet: { tweeet: @tweeet.tweeet } } 38 | assert_redirected_to tweeet_url(@tweeet) 39 | end 40 | 41 | test "should destroy tweeet" do 42 | assert_difference('Tweeet.count', -1) do 43 | delete tweeet_url(@tweeet) 44 | end 45 | 46 | assert_redirected_to tweeets_url 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /app/views/tweeets/_profile.html.erb: -------------------------------------------------------------------------------- 1 |
2 | 44 |
-------------------------------------------------------------------------------- /config/secrets.yml: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key is used for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | 6 | # Make sure the secret is at least 30 characters and all random, 7 | # no regular words or you'll be exposed to dictionary attacks. 8 | # You can use `rails secret` to generate a secure secret key. 9 | 10 | # Make sure the secrets in this file are kept private 11 | # if you're sharing your code publicly. 12 | 13 | # Shared secrets are available across all environments. 14 | 15 | # shared: 16 | # api_key: a1B2c3D4e5F6 17 | 18 | # Environmental secrets are only available for that specific environment. 19 | 20 | development: 21 | secret_key_base: c9854810aa8c8bb606a45d32b3c310888f4428b7519f0a69f3b5708da27cc1d56f17206e6545742505386f170b3204c51fb563e1a0fae15ab3b136b295883721 22 | 23 | test: 24 | secret_key_base: ce47f9837493dde94329bffe8f387530278b9aca365ee5cd4e323f349e94a7e463bdd692f65ae224aadc4247162764bcb779c55dbd8a1ed714c0994735c75703 25 | 26 | # Do not keep production secrets in the unencrypted secrets file. 27 | # Instead, either read values from the environment. 28 | # Or, use `bin/rails secrets:setup` to configure encrypted secrets 29 | # and move the `production:` environment over there. 30 | 31 | production: 32 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> 33 | -------------------------------------------------------------------------------- /app/views/devise/passwords/edit.html.erb: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 | 6 |

Change your password

7 | 8 | <%= simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %> 9 | <%= f.error_notification %> 10 | 11 | <%= f.input :reset_password_token, as: :hidden %> 12 | <%= f.full_error :reset_password_token %> 13 | 14 |
15 |
16 | <%= f.input :password, label: "New password", required: true, autofocus: true, input_html: { class: "input"}, wrapper: false, label_html: { class: "label" }, hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length) %> 17 |
18 |
19 | 20 |
21 |
22 | <%= f.input :password_confirmation, label: "Confirm your new password", input_html: { class: "input"}, wrapper: false, label_html: { class: "label" }, required: true %> 23 |
24 |
25 | 26 |
27 | <%= f.button :submit, "Change my password" %> 28 |
29 | <% end %> 30 | 31 | <%= render "devise/shared/links" %> 32 | 33 |
34 |
35 |
36 |
-------------------------------------------------------------------------------- /app/views/tweeets/_who-to-follow.html.erb: -------------------------------------------------------------------------------- 1 |
2 | 57 |
-------------------------------------------------------------------------------- /db/migrate/20171129234035_devise_create_users.rb: -------------------------------------------------------------------------------- 1 | class DeviseCreateUsers < ActiveRecord::Migration[5.1] 2 | def change 3 | create_table :users do |t| 4 | ## Database authenticatable 5 | t.string :email, null: false, default: "" 6 | t.string :encrypted_password, null: false, default: "" 7 | 8 | ## Recoverable 9 | t.string :reset_password_token 10 | t.datetime :reset_password_sent_at 11 | 12 | ## Rememberable 13 | t.datetime :remember_created_at 14 | 15 | ## Trackable 16 | t.integer :sign_in_count, default: 0, null: false 17 | t.datetime :current_sign_in_at 18 | t.datetime :last_sign_in_at 19 | t.string :current_sign_in_ip 20 | t.string :last_sign_in_ip 21 | 22 | ## Confirmable 23 | # t.string :confirmation_token 24 | # t.datetime :confirmed_at 25 | # t.datetime :confirmation_sent_at 26 | # t.string :unconfirmed_email # Only if using reconfirmable 27 | 28 | ## Lockable 29 | # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts 30 | # t.string :unlock_token # Only if unlock strategy is :email or :both 31 | # t.datetime :locked_at 32 | 33 | 34 | t.timestamps null: false 35 | end 36 | 37 | add_index :users, :email, unique: true 38 | add_index :users, :reset_password_token, unique: true 39 | # add_index :users, :confirmation_token, unique: true 40 | # add_index :users, :unlock_token, unique: true 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /app/views/tweeets/_feed.html.erb: -------------------------------------------------------------------------------- 1 |
2 | <% if user_signed_in? %> 3 |
4 |
5 |

6 | <%= gravatar_image_tag(current_user.email, size: 64, alt: current_user.name) %> 7 |

8 |
9 |
10 | <%= render 'tweeets/form' %> 11 |
12 |
13 | <% end %> 14 | 15 | 16 | <% @tweeets.each do | tweeet | %> 17 |
18 |
19 |
20 |
21 | <%= gravatar_image_tag(tweeet.user.email, size: 64, alt: tweeet.user.name) %> 22 |
23 |
24 |
25 |
26 | <%= tweeet.user.name %>
27 | <%= tweeet.user.username %>
28 |

<%= tweeet.tweeet %>

29 |
30 | <% if user_signed_in? && current_user.id == tweeet.user_id %> 31 | 44 | <% end %> 45 |
46 |
47 |
48 | <% end %> 49 |
-------------------------------------------------------------------------------- /Guardfile: -------------------------------------------------------------------------------- 1 | # A sample Guardfile 2 | # More info at https://github.com/guard/guard#readme 3 | 4 | ## Uncomment and set this to only include directories you want to watch 5 | # directories %w(app lib config test spec features) \ 6 | # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")} 7 | 8 | ## Note: if you are using the `directories` clause above and you are not 9 | ## watching the project directory ('.'), then you will want to move 10 | ## the Guardfile to a watched dir and symlink it back, e.g. 11 | # 12 | # $ mkdir config 13 | # $ mv Guardfile config/ 14 | # $ ln -s config/Guardfile . 15 | # 16 | # and, you'll have to watch "config/Guardfile" instead of "Guardfile" 17 | 18 | guard 'livereload' do 19 | extensions = { 20 | css: :css, 21 | scss: :css, 22 | sass: :css, 23 | js: :js, 24 | coffee: :js, 25 | html: :html, 26 | png: :png, 27 | gif: :gif, 28 | jpg: :jpg, 29 | jpeg: :jpeg, 30 | # less: :less, # uncomment if you want LESS stylesheets done in browser 31 | } 32 | 33 | rails_view_exts = %w(erb haml slim) 34 | 35 | # file types LiveReload may optimize refresh for 36 | compiled_exts = extensions.values.uniq 37 | watch(%r{public/.+\.(#{compiled_exts * '|'})}) 38 | 39 | extensions.each do |ext, type| 40 | watch(%r{ 41 | (?:app|vendor) 42 | (?:/assets/\w+/(?[^.]+) # path+base without extension 43 | (?\.#{ext})) # matching extension (must be first encountered) 44 | (?:\.\w+|$) # other extensions 45 | }x) do |m| 46 | path = m[1] 47 | "/assets/#{path}.#{type}" 48 | end 49 | end 50 | 51 | # file needing a full reload of the page anyway 52 | watch(%r{app/views/.+\.(#{rails_view_exts * '|'})$}) 53 | watch(%r{app/helpers/.+\.rb}) 54 | watch(%r{config/locales/.+\.yml}) 55 | end 56 | -------------------------------------------------------------------------------- /app/views/devise/registrations/new.html.erb: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 5 |
6 | 7 |

Sign Up

8 | 9 | <%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> 10 | <%= f.error_notification %> 11 | 12 |
13 |
14 | <%= f.input :name, required: true, autofocus: true, input_html: { class:"input" }, wrapper: false, label_html: { class:"label" } %> 15 |
16 |
17 | 18 |
19 |
20 | <%= f.input :username, required: true, input_html: { class:"input" }, wrapper: false, label_html: { class:"label" } %> 21 |
22 |
23 | 24 |
25 |
26 | <%= f.input :email, required: true, input_html: { class:"input" }, wrapper: false, label_html: { class:"label" } %> 27 |
28 |
29 | 30 | 31 |
32 |
33 | <%= f.input :password, required: true, input_html: { class:"input" }, wrapper: false, label_html: { class:"label" }, hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length) %> 34 |
35 |
36 | 37 |
38 |
39 | <%= f.input :password_confirmation, required: true, input_html: { class: "input" }, wrapper: false, label_html: { class: "label" } %> 40 |
41 |
42 | 43 |
44 |
45 | <%= f.button :submit, "Sign up", class:"button is-info is-medium" %> 46 |
47 |
48 | 49 | <% end %> 50 |
51 | <%= render "devise/shared/links" %> 52 |
53 |
54 |
55 |
-------------------------------------------------------------------------------- /public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

We're sorry, but something went wrong.

62 |
63 |

If you are the application owner check the logs for more information.

64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Do not eager load code on boot. This avoids loading your whole application 11 | # just for the purpose of running a single test. If you are using a tool that 12 | # preloads Rails for running tests, you may have to set it to true. 13 | config.eager_load = false 14 | 15 | # Configure public file server for tests with Cache-Control for performance. 16 | config.public_file_server.enabled = true 17 | config.public_file_server.headers = { 18 | 'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}" 19 | } 20 | 21 | # Show full error reports and disable caching. 22 | config.consider_all_requests_local = true 23 | config.action_controller.perform_caching = false 24 | 25 | # Raise exceptions instead of rendering exception templates. 26 | config.action_dispatch.show_exceptions = false 27 | 28 | # Disable request forgery protection in test environment. 29 | config.action_controller.allow_forgery_protection = false 30 | config.action_mailer.perform_caching = false 31 | 32 | # Tell Action Mailer not to deliver emails to the real world. 33 | # The :test delivery method accumulates sent emails in the 34 | # ActionMailer::Base.deliveries array. 35 | config.action_mailer.delivery_method = :test 36 | 37 | # Print deprecation notices to the stderr. 38 | config.active_support.deprecation = :stderr 39 | 40 | # Raises error for missing translations 41 | # config.action_view.raise_on_missing_translations = true 42 | end 43 | -------------------------------------------------------------------------------- /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 | # Note that this schema.rb definition is the authoritative source for your 6 | # database schema. If you need to create the application database on another 7 | # system, you should be using db:schema:load, not running all the migrations 8 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations 9 | # you'll amass, the slower it'll run and the greater likelihood for issues). 10 | # 11 | # It's strongly recommended that you check this file into your version control system. 12 | 13 | ActiveRecord::Schema.define(version: 20171130000452) do 14 | 15 | create_table "tweeets", force: :cascade do |t| 16 | t.text "tweeet" 17 | t.datetime "created_at", null: false 18 | t.datetime "updated_at", null: false 19 | t.integer "user_id" 20 | end 21 | 22 | create_table "users", force: :cascade do |t| 23 | t.string "email", default: "", null: false 24 | t.string "encrypted_password", default: "", null: false 25 | t.string "reset_password_token" 26 | t.datetime "reset_password_sent_at" 27 | t.datetime "remember_created_at" 28 | t.integer "sign_in_count", default: 0, null: false 29 | t.datetime "current_sign_in_at" 30 | t.datetime "last_sign_in_at" 31 | t.string "current_sign_in_ip" 32 | t.string "last_sign_in_ip" 33 | t.datetime "created_at", null: false 34 | t.datetime "updated_at", null: false 35 | t.string "name" 36 | t.string "username" 37 | t.index ["email"], name: "index_users_on_email", unique: true 38 | t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true 39 | t.index ["username"], name: "index_users_on_username", unique: true 40 | end 41 | 42 | end 43 | -------------------------------------------------------------------------------- /public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The change you wanted was rejected.

62 |

Maybe you tried to change something you didn't have access to.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The page you were looking for doesn't exist.

62 |

You may have mistyped the address or the page may have moved.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Do not eager load code on boot. 10 | config.eager_load = false 11 | 12 | # Show full error reports. 13 | config.consider_all_requests_local = true 14 | 15 | # Enable/disable caching. By default caching is disabled. 16 | if Rails.root.join('tmp/caching-dev.txt').exist? 17 | config.action_controller.perform_caching = true 18 | 19 | config.cache_store = :memory_store 20 | config.public_file_server.headers = { 21 | 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}" 22 | } 23 | else 24 | config.action_controller.perform_caching = false 25 | 26 | config.cache_store = :null_store 27 | end 28 | 29 | # Don't care if the mailer can't send. 30 | config.action_mailer.raise_delivery_errors = false 31 | 32 | config.action_mailer.perform_caching = false 33 | 34 | # Print deprecation notices to the Rails logger. 35 | config.active_support.deprecation = :log 36 | 37 | # Raise an error on page load if there are pending migrations. 38 | config.active_record.migration_error = :page_load 39 | 40 | # Debug mode disables concatenation and preprocessing of assets. 41 | # This option may cause significant delays in view rendering with a large 42 | # number of complex assets. 43 | config.assets.debug = true 44 | 45 | # Suppress logger output for asset requests. 46 | config.assets.quiet = true 47 | 48 | # Raises error for missing translations 49 | # config.action_view.raise_on_missing_translations = true 50 | 51 | # Use an evented file watcher to asynchronously detect changes in source code, 52 | # routes, locales, etc. This feature depends on the listen gem. 53 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker 54 | # Devise default url 55 | config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } 56 | end 57 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Twittter 5 | <%= csrf_meta_tags %> 6 | 7 | <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> 8 | <%= stylesheet_link_tag "https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" %> 9 | <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> 10 | 11 | 12 | 13 | <% if flash[:notice] %> 14 |
15 |

<%= notice %>

16 |
17 | <% end %> 18 | <% if flash[:alert] %> 19 |
20 |

<%= alert %>

21 |
22 | <% end %> 23 | 62 | 63 | <%= yield %> 64 | 65 | 66 | -------------------------------------------------------------------------------- /app/controllers/tweeets_controller.rb: -------------------------------------------------------------------------------- 1 | class TweeetsController < ApplicationController 2 | before_action :set_tweeet, only: [:show, :edit, :update, :destroy] 3 | before_action :authenticate_user!, except: [:index, :show] 4 | 5 | # GET /tweeets 6 | # GET /tweeets.json 7 | def index 8 | @tweeets = Tweeet.all.order("created_at DESC") 9 | @tweeet = Tweeet.new 10 | end 11 | 12 | # GET /tweeets/1 13 | # GET /tweeets/1.json 14 | def show 15 | end 16 | 17 | # GET /tweeets/new 18 | def new 19 | @tweeet = current_user.tweeets.build 20 | end 21 | 22 | # GET /tweeets/1/edit 23 | def edit 24 | end 25 | 26 | # POST /tweeets 27 | # POST /tweeets.json 28 | def create 29 | @tweeet = current_user.tweeets.build(tweeet_params) 30 | 31 | respond_to do |format| 32 | if @tweeet.save 33 | format.html { redirect_to root_path, notice: 'Tweeet was successfully created.' } 34 | format.json { render :show, status: :created, location: @tweeet } 35 | else 36 | format.html { render :new } 37 | format.json { render json: @tweeet.errors, status: :unprocessable_entity } 38 | end 39 | end 40 | end 41 | 42 | # PATCH/PUT /tweeets/1 43 | # PATCH/PUT /tweeets/1.json 44 | def update 45 | respond_to do |format| 46 | if @tweeet.update(tweeet_params) 47 | format.html { redirect_to @tweeet, notice: 'Tweeet was successfully updated.' } 48 | format.json { render :show, status: :ok, location: @tweeet } 49 | else 50 | format.html { render :edit } 51 | format.json { render json: @tweeet.errors, status: :unprocessable_entity } 52 | end 53 | end 54 | end 55 | 56 | # DELETE /tweeets/1 57 | # DELETE /tweeets/1.json 58 | def destroy 59 | @tweeet.destroy 60 | respond_to do |format| 61 | format.html { redirect_to tweeets_url, notice: 'Tweeet was successfully destroyed.' } 62 | format.json { head :no_content } 63 | end 64 | end 65 | 66 | private 67 | # Use callbacks to share common setup or constraints between actions. 68 | def set_tweeet 69 | @tweeet = Tweeet.find(params[:id]) 70 | end 71 | 72 | # Never trust parameters from the scary internet, only allow the white list through. 73 | def tweeet_params 74 | params.require(:tweeet).permit(:tweeet) 75 | end 76 | end 77 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | git_source(:github) do |repo_name| 4 | repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") 5 | "https://github.com/#{repo_name}.git" 6 | end 7 | 8 | 9 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 10 | gem 'rails', '~> 5.1.4' 11 | # Use sqlite3 as the database for Active Record 12 | gem 'sqlite3' 13 | # Use Puma as the app server 14 | gem 'puma', '~> 3.7' 15 | # Use SCSS for stylesheets 16 | gem 'sass-rails', '~> 5.0' 17 | # Use Uglifier as compressor for JavaScript assets 18 | gem 'uglifier', '>= 1.3.0' 19 | # See https://github.com/rails/execjs#readme for more supported runtimes 20 | # gem 'therubyracer', platforms: :ruby 21 | 22 | # Use CoffeeScript for .coffee assets and views 23 | gem 'coffee-rails', '~> 4.2' 24 | # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 25 | gem 'turbolinks', '~> 5' 26 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 27 | gem 'jbuilder', '~> 2.5' 28 | # Use Redis adapter to run Action Cable in production 29 | # gem 'redis', '~> 3.0' 30 | # Use ActiveModel has_secure_password 31 | # gem 'bcrypt', '~> 3.1.7' 32 | 33 | # Use Capistrano for deployment 34 | # gem 'capistrano-rails', group: :development 35 | 36 | gem 'bulma-rails', '~> 0.6.1' 37 | gem 'simple_form', '~> 3.5' 38 | gem 'gravatar_image_tag', '~> 1.2' 39 | gem 'devise', '~> 4.3' 40 | 41 | 42 | group :development, :test do 43 | # Call 'byebug' anywhere in the code to stop execution and get a debugger console 44 | gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 45 | # Adds support for Capybara system testing and selenium driver 46 | gem 'capybara', '~> 2.13' 47 | gem 'selenium-webdriver' 48 | end 49 | 50 | group :development do 51 | # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. 52 | gem 'web-console', '>= 3.3.0' 53 | gem 'listen', '>= 3.0.5', '< 3.2' 54 | # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 55 | gem 'spring' 56 | gem 'spring-watcher-listen', '~> 2.0.0' 57 | gem 'better_errors', '~> 2.4' 58 | gem 'guard', '~> 2.14', '>= 2.14.1' 59 | gem 'guard-livereload', '~> 2.5', '>= 2.5.2', require: false 60 | end 61 | 62 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem 63 | gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 64 | -------------------------------------------------------------------------------- /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 | threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } 8 | threads threads_count, threads_count 9 | 10 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000. 11 | # 12 | port ENV.fetch("PORT") { 3000 } 13 | 14 | # Specifies the `environment` that Puma will run in. 15 | # 16 | environment ENV.fetch("RAILS_ENV") { "development" } 17 | 18 | # Specifies the number of `workers` to boot in clustered mode. 19 | # Workers are forked webserver processes. If using threads and workers together 20 | # the concurrency of the application would be max `threads` * `workers`. 21 | # Workers do not work on JRuby or Windows (both of which do not support 22 | # processes). 23 | # 24 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 } 25 | 26 | # Use the `preload_app!` method when specifying a `workers` number. 27 | # This directive tells Puma to first boot the application and load code 28 | # before forking the application. This takes advantage of Copy On Write 29 | # process behavior so workers use less memory. If you use this option 30 | # you need to make sure to reconnect any threads in the `on_worker_boot` 31 | # block. 32 | # 33 | # preload_app! 34 | 35 | # If you are preloading your application and using Active Record, it's 36 | # recommended that you close any connections to the database before workers 37 | # are forked to prevent connection leakage. 38 | # 39 | # before_fork do 40 | # ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord) 41 | # end 42 | 43 | # The code in the `on_worker_boot` will be called if you are using 44 | # clustered mode by specifying a number of `workers`. After each worker 45 | # process is booted, this block will be run. If you are using the `preload_app!` 46 | # option, you will want to use this block to reconnect to any threads 47 | # or connections that may have been created at application boot, as Ruby 48 | # cannot share connections between processes. 49 | # 50 | # on_worker_boot do 51 | # ActiveRecord::Base.establish_connection if defined?(ActiveRecord) 52 | # end 53 | # 54 | 55 | # Allow puma to be restarted by `rails restart` command. 56 | plugin :tmp_restart 57 | -------------------------------------------------------------------------------- /app/views/devise/registrations/edit.html.erb: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 | 6 |

Edit <%= resource_name.to_s.humanize %>

7 | <%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> 8 | <%= f.error_notification %> 9 | 10 |
11 |
12 | <%= f.input :name, required: true, autofocus: true, input_html: { class: "input"}, wrapper: false, label_html: { class: "label" } %> 13 |
14 |
15 | 16 |
17 |
18 | <%= f.input :username, required: true, input_html: { class: "input"}, wrapper: false, label_html: { class: "label" } %> 19 |
20 |
21 | 22 |
23 |
24 | <%= f.input :email, required: true, input_html: { class: "input"}, wrapper: false, label_html: { class: "label" } %> 25 |
26 |
27 | 28 |
29 | <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> 30 |

Currently waiting confirmation for: <%= resource.unconfirmed_email %>

31 | <% end %> 32 |
33 | 34 |
35 |
36 | <%= f.input :password, autocomplete: "off", hint: "leave it blank if you don't want to change it", required: false, input_html: { class: "input"}, wrapper: false, label_html: { class: "label" } %> 37 |
38 |
39 | 40 |
41 |
42 | <%= f.input :password_confirmation, required: false, input_html: { class: "input"}, wrapper: false, label_html: { class: "label" } %> 43 |
44 |
45 | 46 |
47 |
48 | <%= f.input :current_password, hint: "we need your current password to confirm your changes", required: true, input_html: { class: "input"}, wrapper: false, label_html: { class: "label" } %> 49 |
50 |
51 | 52 | <%= f.button :submit, "Update", class:"button is-info" %> 53 | 54 | <% end %> 55 | 56 |
57 |

Cancel my account

58 |

Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %>

59 | 60 |
61 |
62 |
63 |
-------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Let's Build: With Ruby on Rails - A Twitter Clone 2 | 3 | ![feature-image](https://i.imgur.com/6QHjYJF.jpg) 4 | 5 | 6 | 7 | Welcome to our next Let's Build! This build introduces a well known social media giant Twitter into the mix as inspiration for the project. We will be creating a knock-off of sorts called **Twittter**. 8 | 9 | This app will most notably demonstrate a user role system giving your web application and navtive application feel all within the browser. I'll be going bit faster than the [previous build](https://web-crunch.com/lets-build-with-ruby-on-rails-blog-with-comments/) as it was more of a foundational exercise where I explained common concepts revolving around the Ruby on Rails ecosystem. We'll make use of Rails generators to help scaffold some of the things I've already covered. If you haven't watched the [first Let's Build](https://web-crunch.com/lets-build-with-ruby-on-rails-blog-with-comments/), I invite you to do so in order to understand what we are doing. 10 | 11 | #### Download the source code 12 | 13 | [Download the source code](https://github.com/justalever/twittter) 14 | 15 | ### What we are building 16 | 17 | The app itself will feature a basic CRUD principle where we can create, read, update, and destroy *Tweeets*. In essence, this is the same as my previous build where we created posts for a blog. On top of the *Tweeets*, I introduce a new gem called [Devise](https://github.com/plataformatec/devise) which makes creating an entire user role and authentication system easy. Combined with this gem we can authenticate users who want to author *Tweeets*. A user's *Tweeets* are then also tied to their account. The end result is a public facing site with a stream of tweets from different users. Users that have and account can login to create their own *Tweeets* to add to the public stream. 18 | 19 | ### What we won't be covering 20 | 21 | Twitter is pretty elaborate application. I won't be covering replies, retweets, likes, and quite a few other foundational features of the famous social media giant. Instead I invite you to tinker with how to possible add those features. Similar to the [blog with comments build](https://web-crunch.com/lets-build-with-ruby-on-rails-blog-with-comments/) I did, see if you can figure out how to add replies to the application on your own. (Tip: It's the same as adding comments to the blog post as I did in the previous build ;) ). I may revisit this app to add more features as another exercise but I truthfully ran out of time! Let me know if you'd like to see me extend this further. 22 | 23 | There are also a few gems in the wild for "liking" posts. [Here's a favorite of mine](https://github.com/schneems/Likeable) 24 | 25 | **Note:** One big error I noticed after calling it quits on this build was that any logged in user could edit **any** other user's tweeets. This is a big security flaw as a user's abilities should only lie within their own account. See if you can find a way to only allow the current logged in user to edit their own tweets and not other users. I may revisit this series to extend and address these issues. 26 | 27 | ### Ruby gems used in this build 28 | 29 | - [Better Errors](https://rubygems.org/gems/better_errors) - For better errors 30 | 31 | - [Bulma](https://github.com/joshuajansen/bulma-rails) - for easy CSS. Feel free to roll your own styles and/or use a different framework. 32 | 33 | - [Guard](https://github.com/guard/guard) - Useful for live reloading our `scss`, `js`, `css`, and `erb` files, although it's capable of much more! 34 | 35 | *Guard is required for the Guard LiveReload gem to work* 36 | 37 | - [Guard LiveReload](https://github.com/guard/guard-livereload) 38 | 39 | - [Simple Form](https://github.com/plataformatec/simple_form) - For simple forms! 40 | 41 | - [Devise](https://github.com/plataformatec/devise) - Effortless user roles and authentication 42 | 43 | - [Gravatar_image_tag](https://github.com/mdeering/gravatar_image_tag) - Integrated image tag which spits out gravatars. 44 | 45 | ​ 46 | 47 | Continue reading on [web-crunch.com](https://web-crunch.com/lets-build-with-ruby-on-rails-a-twitter-clone/) 48 | -------------------------------------------------------------------------------- /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 | # Attempt to read encrypted secrets from `config/secrets.yml.enc`. 18 | # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or 19 | # `config/secrets.yml.key`. 20 | config.read_encrypted_secrets = true 21 | 22 | # Disable serving static files from the `/public` folder by default since 23 | # Apache or NGINX already handles this. 24 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? 25 | 26 | # Compress JavaScripts and CSS. 27 | config.assets.js_compressor = :uglifier 28 | # config.assets.css_compressor = :sass 29 | 30 | # Do not fallback to assets pipeline if a precompiled asset is missed. 31 | config.assets.compile = false 32 | 33 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb 34 | 35 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 36 | # config.action_controller.asset_host = 'http://assets.example.com' 37 | 38 | # Specifies the header that your server uses for sending files. 39 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache 40 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX 41 | 42 | # Mount Action Cable outside main process or domain 43 | # config.action_cable.mount_path = nil 44 | # config.action_cable.url = 'wss://example.com/cable' 45 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] 46 | 47 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 48 | # config.force_ssl = true 49 | 50 | # Use the lowest log level to ensure availability of diagnostic information 51 | # when problems arise. 52 | config.log_level = :debug 53 | 54 | # Prepend all log lines with the following tags. 55 | config.log_tags = [ :request_id ] 56 | 57 | # Use a different cache store in production. 58 | # config.cache_store = :mem_cache_store 59 | 60 | # Use a real queuing backend for Active Job (and separate queues per environment) 61 | # config.active_job.queue_adapter = :resque 62 | # config.active_job.queue_name_prefix = "twittter_#{Rails.env}" 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 | end 92 | -------------------------------------------------------------------------------- /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 confirm link to confirm your new email address." 46 | updated: "Your account has been updated successfully." 47 | sessions: 48 | signed_in: "Signed in successfully." 49 | signed_out: "Signed out successfully." 50 | already_signed_out: "Signed out successfully." 51 | unlocks: 52 | send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes." 53 | send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes." 54 | unlocked: "Your account has been unlocked successfully. Please sign in to continue." 55 | errors: 56 | messages: 57 | already_confirmed: "was already confirmed, please try signing in" 58 | confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one" 59 | expired: "has expired, please request a new one" 60 | not_found: "not found" 61 | not_locked: "was not locked" 62 | not_saved: 63 | one: "1 error prohibited this %{resource} from being saved:" 64 | other: "%{count} errors prohibited this %{resource} from being saved:" 65 | -------------------------------------------------------------------------------- /config/initializers/simple_form.rb: -------------------------------------------------------------------------------- 1 | # Use this setup block to configure all options available in SimpleForm. 2 | SimpleForm.setup do |config| 3 | # Wrappers are used by the form builder to generate a 4 | # complete input. You can remove any component from the 5 | # wrapper, change the order or even add your own to the 6 | # stack. The options given below are used to wrap the 7 | # whole input. 8 | config.wrappers :default, class: :input, 9 | hint_class: :field_with_hint, error_class: :field_with_errors do |b| 10 | ## Extensions enabled by default 11 | # Any of these extensions can be disabled for a 12 | # given input by passing: `f.input EXTENSION_NAME => false`. 13 | # You can make any of these extensions optional by 14 | # renaming `b.use` to `b.optional`. 15 | 16 | # Determines whether to use HTML5 (:email, :url, ...) 17 | # and required attributes 18 | b.use :html5 19 | 20 | # Calculates placeholders automatically from I18n 21 | # You can also pass a string as f.input placeholder: "Placeholder" 22 | b.use :placeholder 23 | 24 | ## Optional extensions 25 | # They are disabled unless you pass `f.input EXTENSION_NAME => true` 26 | # to the input. If so, they will retrieve the values from the model 27 | # if any exists. If you want to enable any of those 28 | # extensions by default, you can change `b.optional` to `b.use`. 29 | 30 | # Calculates maxlength from length validations for string inputs 31 | # and/or database column lengths 32 | b.optional :maxlength 33 | 34 | # Calculate minlength from length validations for string inputs 35 | b.optional :minlength 36 | 37 | # Calculates pattern from format validations for string inputs 38 | b.optional :pattern 39 | 40 | # Calculates min and max from length validations for numeric inputs 41 | b.optional :min_max 42 | 43 | # Calculates readonly automatically from readonly attributes 44 | b.optional :readonly 45 | 46 | ## Inputs 47 | b.use :label_input 48 | b.use :hint, wrap_with: { tag: :span, class: :hint } 49 | b.use :error, wrap_with: { tag: :span, class: :error } 50 | 51 | ## full_messages_for 52 | # If you want to display the full error message for the attribute, you can 53 | # use the component :full_error, like: 54 | # 55 | # b.use :full_error, wrap_with: { tag: :span, class: :error } 56 | end 57 | 58 | # The default wrapper to be used by the FormBuilder. 59 | config.default_wrapper = :default 60 | 61 | # Define the way to render check boxes / radio buttons with labels. 62 | # Defaults to :nested for bootstrap config. 63 | # inline: input + label 64 | # nested: label > input 65 | config.boolean_style = :nested 66 | 67 | # Default class for buttons 68 | config.button_class = 'btn' 69 | 70 | # Method used to tidy up errors. Specify any Rails Array method. 71 | # :first lists the first message for each field. 72 | # Use :to_sentence to list all errors for each field. 73 | # config.error_method = :first 74 | 75 | # Default tag used for error notification helper. 76 | config.error_notification_tag = :div 77 | 78 | # CSS class to add for error notification helper. 79 | config.error_notification_class = 'error_notification' 80 | 81 | # ID to add for error notification helper. 82 | # config.error_notification_id = nil 83 | 84 | # Series of attempts to detect a default label method for collection. 85 | # config.collection_label_methods = [ :to_label, :name, :title, :to_s ] 86 | 87 | # Series of attempts to detect a default value method for collection. 88 | # config.collection_value_methods = [ :id, :to_s ] 89 | 90 | # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none. 91 | # config.collection_wrapper_tag = nil 92 | 93 | # You can define the class to use on all collection wrappers. Defaulting to none. 94 | # config.collection_wrapper_class = nil 95 | 96 | # You can wrap each item in a collection of radio/check boxes with a tag, 97 | # defaulting to :span. 98 | # config.item_wrapper_tag = :span 99 | 100 | # You can define a class to use in all item wrappers. Defaulting to none. 101 | # config.item_wrapper_class = nil 102 | 103 | # How the label text should be generated altogether with the required text. 104 | # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" } 105 | 106 | # You can define the class to use on all labels. Default is nil. 107 | # config.label_class = nil 108 | 109 | # You can define the default class to be used on forms. Can be overriden 110 | # with `html: { :class }`. Defaulting to none. 111 | # config.default_form_class = nil 112 | 113 | # You can define which elements should obtain additional classes 114 | # config.generate_additional_classes_for = [:wrapper, :label, :input] 115 | 116 | # Whether attributes are required by default (or not). Default is true. 117 | # config.required_by_default = true 118 | 119 | # Tell browsers whether to use the native HTML5 validations (novalidate form option). 120 | # These validations are enabled in SimpleForm's internal config but disabled by default 121 | # in this configuration, which is recommended due to some quirks from different browsers. 122 | # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations, 123 | # change this configuration to true. 124 | config.browser_validations = false 125 | 126 | # Collection of methods to detect if a file type was given. 127 | # config.file_methods = [ :mounted_as, :file?, :public_filename ] 128 | 129 | # Custom mappings for input types. This should be a hash containing a regexp 130 | # to match as key, and the input type that will be used when the field name 131 | # matches the regexp as value. 132 | # config.input_mappings = { /count/ => :integer } 133 | 134 | # Custom wrappers for input types. This should be a hash containing an input 135 | # type as key and the wrapper that will be used for all inputs with specified type. 136 | # config.wrapper_mappings = { string: :prepend } 137 | 138 | # Namespaces where SimpleForm should look for custom input classes that 139 | # override default inputs. 140 | # config.custom_inputs_namespaces << "CustomInputs" 141 | 142 | # Default priority for time_zone inputs. 143 | # config.time_zone_priority = nil 144 | 145 | # Default priority for country inputs. 146 | # config.country_priority = nil 147 | 148 | # When false, do not use translations for labels. 149 | # config.translate_labels = true 150 | 151 | # Automatically discover new inputs in Rails' autoload path. 152 | # config.inputs_discovery = true 153 | 154 | # Cache SimpleForm inputs discovery 155 | # config.cache_discovery = !Rails.env.development? 156 | 157 | # Default class for inputs 158 | # config.input_class = nil 159 | 160 | # Define the default class of the input wrapper of the boolean input. 161 | config.boolean_label_class = 'checkbox' 162 | 163 | # Defines if the default input wrapper class should be included in radio 164 | # collection wrappers. 165 | # config.include_default_input_wrapper_class = true 166 | 167 | # Defines which i18n scope will be used in Simple Form. 168 | # config.i18n_scope = 'simple_form' 169 | end 170 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actioncable (5.1.4) 5 | actionpack (= 5.1.4) 6 | nio4r (~> 2.0) 7 | websocket-driver (~> 0.6.1) 8 | actionmailer (5.1.4) 9 | actionpack (= 5.1.4) 10 | actionview (= 5.1.4) 11 | activejob (= 5.1.4) 12 | mail (~> 2.5, >= 2.5.4) 13 | rails-dom-testing (~> 2.0) 14 | actionpack (5.1.4) 15 | actionview (= 5.1.4) 16 | activesupport (= 5.1.4) 17 | rack (~> 2.0) 18 | rack-test (>= 0.6.3) 19 | rails-dom-testing (~> 2.0) 20 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 21 | actionview (5.1.4) 22 | activesupport (= 5.1.4) 23 | builder (~> 3.1) 24 | erubi (~> 1.4) 25 | rails-dom-testing (~> 2.0) 26 | rails-html-sanitizer (~> 1.0, >= 1.0.3) 27 | activejob (5.1.4) 28 | activesupport (= 5.1.4) 29 | globalid (>= 0.3.6) 30 | activemodel (5.1.4) 31 | activesupport (= 5.1.4) 32 | activerecord (5.1.4) 33 | activemodel (= 5.1.4) 34 | activesupport (= 5.1.4) 35 | arel (~> 8.0) 36 | activesupport (5.1.4) 37 | concurrent-ruby (~> 1.0, >= 1.0.2) 38 | i18n (~> 0.7) 39 | minitest (~> 5.1) 40 | tzinfo (~> 1.1) 41 | addressable (2.5.2) 42 | public_suffix (>= 2.0.2, < 4.0) 43 | arel (8.0.0) 44 | bcrypt (3.1.11) 45 | better_errors (2.4.0) 46 | coderay (>= 1.0.0) 47 | erubi (>= 1.0.0) 48 | rack (>= 0.9.0) 49 | bindex (0.5.0) 50 | builder (3.2.3) 51 | bulma-rails (0.6.1) 52 | sass (~> 3.2) 53 | byebug (9.1.0) 54 | capybara (2.16.1) 55 | addressable 56 | mini_mime (>= 0.1.3) 57 | nokogiri (>= 1.3.3) 58 | rack (>= 1.0.0) 59 | rack-test (>= 0.5.4) 60 | xpath (~> 2.0) 61 | childprocess (0.8.0) 62 | ffi (~> 1.0, >= 1.0.11) 63 | coderay (1.1.2) 64 | coffee-rails (4.2.2) 65 | coffee-script (>= 2.2.0) 66 | railties (>= 4.0.0) 67 | coffee-script (2.4.1) 68 | coffee-script-source 69 | execjs 70 | coffee-script-source (1.12.2) 71 | concurrent-ruby (1.0.5) 72 | crass (1.0.3) 73 | devise (4.3.0) 74 | bcrypt (~> 3.0) 75 | orm_adapter (~> 0.1) 76 | railties (>= 4.1.0, < 5.2) 77 | responders 78 | warden (~> 1.2.3) 79 | em-websocket (0.5.1) 80 | eventmachine (>= 0.12.9) 81 | http_parser.rb (~> 0.6.0) 82 | erubi (1.7.0) 83 | eventmachine (1.2.5) 84 | execjs (2.7.0) 85 | ffi (1.9.18) 86 | formatador (0.2.5) 87 | globalid (0.4.1) 88 | activesupport (>= 4.2.0) 89 | gravatar_image_tag (1.2.0) 90 | guard (2.14.1) 91 | formatador (>= 0.2.4) 92 | listen (>= 2.7, < 4.0) 93 | lumberjack (~> 1.0) 94 | nenv (~> 0.1) 95 | notiffany (~> 0.0) 96 | pry (>= 0.9.12) 97 | shellany (~> 0.0) 98 | thor (>= 0.18.1) 99 | guard-compat (1.2.1) 100 | guard-livereload (2.5.2) 101 | em-websocket (~> 0.5) 102 | guard (~> 2.8) 103 | guard-compat (~> 1.0) 104 | multi_json (~> 1.8) 105 | http_parser.rb (0.6.0) 106 | i18n (0.9.1) 107 | concurrent-ruby (~> 1.0) 108 | jbuilder (2.7.0) 109 | activesupport (>= 4.2.0) 110 | multi_json (>= 1.2) 111 | listen (3.1.5) 112 | rb-fsevent (~> 0.9, >= 0.9.4) 113 | rb-inotify (~> 0.9, >= 0.9.7) 114 | ruby_dep (~> 1.2) 115 | loofah (2.1.1) 116 | crass (~> 1.0.2) 117 | nokogiri (>= 1.5.9) 118 | lumberjack (1.0.12) 119 | mail (2.7.0) 120 | mini_mime (>= 0.1.1) 121 | method_source (0.9.0) 122 | mini_mime (1.0.0) 123 | mini_portile2 (2.3.0) 124 | minitest (5.10.3) 125 | multi_json (1.12.2) 126 | nenv (0.3.0) 127 | nio4r (2.1.0) 128 | nokogiri (1.8.1) 129 | mini_portile2 (~> 2.3.0) 130 | notiffany (0.1.1) 131 | nenv (~> 0.1) 132 | shellany (~> 0.0) 133 | orm_adapter (0.5.0) 134 | pry (0.11.3) 135 | coderay (~> 1.1.0) 136 | method_source (~> 0.9.0) 137 | public_suffix (3.0.1) 138 | puma (3.11.0) 139 | rack (2.0.3) 140 | rack-test (0.8.2) 141 | rack (>= 1.0, < 3) 142 | rails (5.1.4) 143 | actioncable (= 5.1.4) 144 | actionmailer (= 5.1.4) 145 | actionpack (= 5.1.4) 146 | actionview (= 5.1.4) 147 | activejob (= 5.1.4) 148 | activemodel (= 5.1.4) 149 | activerecord (= 5.1.4) 150 | activesupport (= 5.1.4) 151 | bundler (>= 1.3.0) 152 | railties (= 5.1.4) 153 | sprockets-rails (>= 2.0.0) 154 | rails-dom-testing (2.0.3) 155 | activesupport (>= 4.2.0) 156 | nokogiri (>= 1.6) 157 | rails-html-sanitizer (1.0.3) 158 | loofah (~> 2.0) 159 | railties (5.1.4) 160 | actionpack (= 5.1.4) 161 | activesupport (= 5.1.4) 162 | method_source 163 | rake (>= 0.8.7) 164 | thor (>= 0.18.1, < 2.0) 165 | rake (12.3.0) 166 | rb-fsevent (0.10.2) 167 | rb-inotify (0.9.10) 168 | ffi (>= 0.5.0, < 2) 169 | responders (2.4.0) 170 | actionpack (>= 4.2.0, < 5.3) 171 | railties (>= 4.2.0, < 5.3) 172 | ruby_dep (1.5.0) 173 | rubyzip (1.2.1) 174 | sass (3.5.3) 175 | sass-listen (~> 4.0.0) 176 | sass-listen (4.0.0) 177 | rb-fsevent (~> 0.9, >= 0.9.4) 178 | rb-inotify (~> 0.9, >= 0.9.7) 179 | sass-rails (5.0.7) 180 | railties (>= 4.0.0, < 6) 181 | sass (~> 3.1) 182 | sprockets (>= 2.8, < 4.0) 183 | sprockets-rails (>= 2.0, < 4.0) 184 | tilt (>= 1.1, < 3) 185 | selenium-webdriver (3.7.0) 186 | childprocess (~> 0.5) 187 | rubyzip (~> 1.0) 188 | shellany (0.0.1) 189 | simple_form (3.5.0) 190 | actionpack (> 4, < 5.2) 191 | activemodel (> 4, < 5.2) 192 | spring (2.0.2) 193 | activesupport (>= 4.2) 194 | spring-watcher-listen (2.0.1) 195 | listen (>= 2.7, < 4.0) 196 | spring (>= 1.2, < 3.0) 197 | sprockets (3.7.1) 198 | concurrent-ruby (~> 1.0) 199 | rack (> 1, < 3) 200 | sprockets-rails (3.2.1) 201 | actionpack (>= 4.0) 202 | activesupport (>= 4.0) 203 | sprockets (>= 3.0.0) 204 | sqlite3 (1.3.13) 205 | thor (0.20.0) 206 | thread_safe (0.3.6) 207 | tilt (2.0.8) 208 | turbolinks (5.0.1) 209 | turbolinks-source (~> 5) 210 | turbolinks-source (5.0.3) 211 | tzinfo (1.2.4) 212 | thread_safe (~> 0.1) 213 | uglifier (3.2.0) 214 | execjs (>= 0.3.0, < 3) 215 | warden (1.2.7) 216 | rack (>= 1.0) 217 | web-console (3.5.1) 218 | actionview (>= 5.0) 219 | activemodel (>= 5.0) 220 | bindex (>= 0.4.0) 221 | railties (>= 5.0) 222 | websocket-driver (0.6.5) 223 | websocket-extensions (>= 0.1.0) 224 | websocket-extensions (0.1.3) 225 | xpath (2.1.0) 226 | nokogiri (~> 1.3) 227 | 228 | PLATFORMS 229 | ruby 230 | 231 | DEPENDENCIES 232 | better_errors (~> 2.4) 233 | bulma-rails (~> 0.6.1) 234 | byebug 235 | capybara (~> 2.13) 236 | coffee-rails (~> 4.2) 237 | devise (~> 4.3) 238 | gravatar_image_tag (~> 1.2) 239 | guard (~> 2.14, >= 2.14.1) 240 | guard-livereload (~> 2.5, >= 2.5.2) 241 | jbuilder (~> 2.5) 242 | listen (>= 3.0.5, < 3.2) 243 | puma (~> 3.7) 244 | rails (~> 5.1.4) 245 | sass-rails (~> 5.0) 246 | selenium-webdriver 247 | simple_form (~> 3.5) 248 | spring 249 | spring-watcher-listen (~> 2.0.0) 250 | sqlite3 251 | turbolinks (~> 5) 252 | tzinfo-data 253 | uglifier (>= 1.3.0) 254 | web-console (>= 3.3.0) 255 | 256 | BUNDLED WITH 257 | 1.16.0 258 | -------------------------------------------------------------------------------- /config/initializers/devise.rb: -------------------------------------------------------------------------------- 1 | # Use this hook to configure devise mailer, warden hooks and so forth. 2 | # Many of these configuration options can be set straight in your model. 3 | Devise.setup do |config| 4 | # The secret key used by Devise. Devise uses this key to generate 5 | # random tokens. Changing this key will render invalid all existing 6 | # confirmation, reset password and unlock tokens in the database. 7 | # Devise will use the `secret_key_base` as its `secret_key` 8 | # by default. You can change it below and use your own secret key. 9 | # config.secret_key = '27870c42e522bbf8d1998efabeccfdadb5ada8fbf1f4c5b8556feb4d39f120683fbe9345ffa0057d2e124a9794ccac63c155d2b45ca895c73a9e9d786d14b2f4' 10 | 11 | # ==> Mailer Configuration 12 | # Configure the e-mail address which will be shown in Devise::Mailer, 13 | # note that it will be overwritten if you use your own mailer class 14 | # with default "from" parameter. 15 | config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com' 16 | 17 | # Configure the class responsible to send e-mails. 18 | # config.mailer = 'Devise::Mailer' 19 | 20 | # Configure the parent class responsible to send e-mails. 21 | # config.parent_mailer = 'ActionMailer::Base' 22 | 23 | # ==> ORM configuration 24 | # Load and configure the ORM. Supports :active_record (default) and 25 | # :mongoid (bson_ext recommended) by default. Other ORMs may be 26 | # available as additional gems. 27 | require 'devise/orm/active_record' 28 | 29 | # ==> Configuration for any authentication mechanism 30 | # Configure which keys are used when authenticating a user. The default is 31 | # just :email. You can configure it to use [:username, :subdomain], so for 32 | # authenticating a user, both parameters are required. Remember that those 33 | # parameters are used only when authenticating and not when retrieving from 34 | # session. If you need permissions, you should implement that in a before filter. 35 | # You can also supply a hash where the value is a boolean determining whether 36 | # or not authentication should be aborted when the value is not present. 37 | # config.authentication_keys = [:email] 38 | 39 | # Configure parameters from the request object used for authentication. Each entry 40 | # given should be a request method and it will automatically be passed to the 41 | # find_for_authentication method and considered in your model lookup. For instance, 42 | # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. 43 | # The same considerations mentioned for authentication_keys also apply to request_keys. 44 | # config.request_keys = [] 45 | 46 | # Configure which authentication keys should be case-insensitive. 47 | # These keys will be downcased upon creating or modifying a user and when used 48 | # to authenticate or find a user. Default is :email. 49 | config.case_insensitive_keys = [:email] 50 | 51 | # Configure which authentication keys should have whitespace stripped. 52 | # These keys will have whitespace before and after removed upon creating or 53 | # modifying a user and when used to authenticate or find a user. Default is :email. 54 | config.strip_whitespace_keys = [:email] 55 | 56 | # Tell if authentication through request.params is enabled. True by default. 57 | # It can be set to an array that will enable params authentication only for the 58 | # given strategies, for example, `config.params_authenticatable = [:database]` will 59 | # enable it only for database (email + password) authentication. 60 | # config.params_authenticatable = true 61 | 62 | # Tell if authentication through HTTP Auth is enabled. False by default. 63 | # It can be set to an array that will enable http authentication only for the 64 | # given strategies, for example, `config.http_authenticatable = [:database]` will 65 | # enable it only for database authentication. The supported strategies are: 66 | # :database = Support basic authentication with authentication key + password 67 | # config.http_authenticatable = false 68 | 69 | # If 401 status code should be returned for AJAX requests. True by default. 70 | # config.http_authenticatable_on_xhr = true 71 | 72 | # The realm used in Http Basic Authentication. 'Application' by default. 73 | # config.http_authentication_realm = 'Application' 74 | 75 | # It will change confirmation, password recovery and other workflows 76 | # to behave the same regardless if the e-mail provided was right or wrong. 77 | # Does not affect registerable. 78 | # config.paranoid = true 79 | 80 | # By default Devise will store the user in session. You can skip storage for 81 | # particular strategies by setting this option. 82 | # Notice that if you are skipping storage for all authentication paths, you 83 | # may want to disable generating routes to Devise's sessions controller by 84 | # passing skip: :sessions to `devise_for` in your config/routes.rb 85 | config.skip_session_storage = [:http_auth] 86 | 87 | # By default, Devise cleans up the CSRF token on authentication to 88 | # avoid CSRF token fixation attacks. This means that, when using AJAX 89 | # requests for sign in and sign up, you need to get a new CSRF token 90 | # from the server. You can disable this option at your own risk. 91 | # config.clean_up_csrf_token_on_authentication = true 92 | 93 | # When false, Devise will not attempt to reload routes on eager load. 94 | # This can reduce the time taken to boot the app but if your application 95 | # requires the Devise mappings to be loaded during boot time the application 96 | # won't boot properly. 97 | # config.reload_routes = true 98 | 99 | # ==> Configuration for :database_authenticatable 100 | # For bcrypt, this is the cost for hashing the password and defaults to 11. If 101 | # using other algorithms, it sets how many times you want the password to be hashed. 102 | # 103 | # Limiting the stretches to just one in testing will increase the performance of 104 | # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use 105 | # a value less than 10 in other environments. Note that, for bcrypt (the default 106 | # algorithm), the cost increases exponentially with the number of stretches (e.g. 107 | # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation). 108 | config.stretches = Rails.env.test? ? 1 : 11 109 | 110 | # Set up a pepper to generate the hashed password. 111 | # config.pepper = 'a10c0661b6604be6275488f9f18c93fd2fd12e07b6c356b5677e3e66ce8eb8193841c0fa0b1bad79d8bcb5eb4e35c9b92f9f28adaa797266787a163ffdde3fb5' 112 | 113 | # Send a notification to the original email when the user's email is changed. 114 | # config.send_email_changed_notification = false 115 | 116 | # Send a notification email when the user's password is changed. 117 | # config.send_password_change_notification = false 118 | 119 | # ==> Configuration for :confirmable 120 | # A period that the user is allowed to access the website even without 121 | # confirming their account. For instance, if set to 2.days, the user will be 122 | # able to access the website for two days without confirming their account, 123 | # access will be blocked just in the third day. Default is 0.days, meaning 124 | # the user cannot access the website without confirming their account. 125 | # config.allow_unconfirmed_access_for = 2.days 126 | 127 | # A period that the user is allowed to confirm their account before their 128 | # token becomes invalid. For example, if set to 3.days, the user can confirm 129 | # their account within 3 days after the mail was sent, but on the fourth day 130 | # their account can't be confirmed with the token any more. 131 | # Default is nil, meaning there is no restriction on how long a user can take 132 | # before confirming their account. 133 | # config.confirm_within = 3.days 134 | 135 | # If true, requires any email changes to be confirmed (exactly the same way as 136 | # initial account confirmation) to be applied. Requires additional unconfirmed_email 137 | # db field (see migrations). Until confirmed, new email is stored in 138 | # unconfirmed_email column, and copied to email column on successful confirmation. 139 | config.reconfirmable = true 140 | 141 | # Defines which key will be used when confirming an account 142 | # config.confirmation_keys = [:email] 143 | 144 | # ==> Configuration for :rememberable 145 | # The time the user will be remembered without asking for credentials again. 146 | # config.remember_for = 2.weeks 147 | 148 | # Invalidates all the remember me tokens when the user signs out. 149 | config.expire_all_remember_me_on_sign_out = true 150 | 151 | # If true, extends the user's remember period when remembered via cookie. 152 | # config.extend_remember_period = false 153 | 154 | # Options to be passed to the created cookie. For instance, you can set 155 | # secure: true in order to force SSL only cookies. 156 | # config.rememberable_options = {} 157 | 158 | # ==> Configuration for :validatable 159 | # Range for password length. 160 | config.password_length = 6..128 161 | 162 | # Email regex used to validate email formats. It simply asserts that 163 | # one (and only one) @ exists in the given string. This is mainly 164 | # to give user feedback and not to assert the e-mail validity. 165 | config.email_regexp = /\A[^@\s]+@[^@\s]+\z/ 166 | 167 | # ==> Configuration for :timeoutable 168 | # The time you want to timeout the user session without activity. After this 169 | # time the user will be asked for credentials again. Default is 30 minutes. 170 | # config.timeout_in = 30.minutes 171 | 172 | # ==> Configuration for :lockable 173 | # Defines which strategy will be used to lock an account. 174 | # :failed_attempts = Locks an account after a number of failed attempts to sign in. 175 | # :none = No lock strategy. You should handle locking by yourself. 176 | # config.lock_strategy = :failed_attempts 177 | 178 | # Defines which key will be used when locking and unlocking an account 179 | # config.unlock_keys = [:email] 180 | 181 | # Defines which strategy will be used to unlock an account. 182 | # :email = Sends an unlock link to the user email 183 | # :time = Re-enables login after a certain amount of time (see :unlock_in below) 184 | # :both = Enables both strategies 185 | # :none = No unlock strategy. You should handle unlocking by yourself. 186 | # config.unlock_strategy = :both 187 | 188 | # Number of authentication tries before locking an account if lock_strategy 189 | # is failed attempts. 190 | # config.maximum_attempts = 20 191 | 192 | # Time interval to unlock the account if :time is enabled as unlock_strategy. 193 | # config.unlock_in = 1.hour 194 | 195 | # Warn on the last attempt before the account is locked. 196 | # config.last_attempt_warning = true 197 | 198 | # ==> Configuration for :recoverable 199 | # 200 | # Defines which key will be used when recovering the password for an account 201 | # config.reset_password_keys = [:email] 202 | 203 | # Time interval you can reset your password with a reset password key. 204 | # Don't put a too small interval or your users won't have the time to 205 | # change their passwords. 206 | config.reset_password_within = 6.hours 207 | 208 | # When set to false, does not sign a user in automatically after their password is 209 | # reset. Defaults to true, so a user is signed in automatically after a reset. 210 | # config.sign_in_after_reset_password = true 211 | 212 | # ==> Configuration for :encryptable 213 | # Allow you to use another hashing or encryption algorithm besides bcrypt (default). 214 | # You can use :sha1, :sha512 or algorithms from others authentication tools as 215 | # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20 216 | # for default behavior) and :restful_authentication_sha1 (then you should set 217 | # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper). 218 | # 219 | # Require the `devise-encryptable` gem when using anything other than bcrypt 220 | # config.encryptor = :sha512 221 | 222 | # ==> Scopes configuration 223 | # Turn scoped views on. Before rendering "sessions/new", it will first check for 224 | # "users/sessions/new". It's turned off by default because it's slower if you 225 | # are using only default views. 226 | # config.scoped_views = false 227 | 228 | # Configure the default scope given to Warden. By default it's the first 229 | # devise role declared in your routes (usually :user). 230 | # config.default_scope = :user 231 | 232 | # Set this configuration to false if you want /users/sign_out to sign out 233 | # only the current scope. By default, Devise signs out all scopes. 234 | # config.sign_out_all_scopes = true 235 | 236 | # ==> Navigation configuration 237 | # Lists the formats that should be treated as navigational. Formats like 238 | # :html, should redirect to the sign in page when the user does not have 239 | # access, but formats like :xml or :json, should return 401. 240 | # 241 | # If you have any extra navigational formats, like :iphone or :mobile, you 242 | # should add them to the navigational formats lists. 243 | # 244 | # The "*/*" below is required to match Internet Explorer requests. 245 | # config.navigational_formats = ['*/*', :html] 246 | 247 | # The default HTTP method used to sign out a resource. Default is :delete. 248 | config.sign_out_via = :delete 249 | 250 | # ==> OmniAuth 251 | # Add a new OmniAuth provider. Check the wiki for more information on setting 252 | # up on your models and hooks. 253 | # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo' 254 | 255 | # ==> Warden configuration 256 | # If you want to use other strategies, that are not supported by Devise, or 257 | # change the failure app, you can configure them inside the config.warden block. 258 | # 259 | # config.warden do |manager| 260 | # manager.intercept_401 = false 261 | # manager.default_strategies(scope: :user).unshift :some_external_strategy 262 | # end 263 | 264 | # ==> Mountable engine configurations 265 | # When using Devise inside an engine, let's call it `MyEngine`, and this engine 266 | # is mountable, there are some extra configurations to be taken into account. 267 | # The following options are available, assuming the engine is mounted as: 268 | # 269 | # mount MyEngine, at: '/my_engine' 270 | # 271 | # The router that invoked `devise_for`, in the example above, would be: 272 | # config.router_name = :my_engine 273 | # 274 | # When using OmniAuth, Devise cannot automatically set OmniAuth path, 275 | # so you need to do it manually. For the users scope, it would be: 276 | # config.omniauth_path_prefix = '/my_engine/users/auth' 277 | end 278 | --------------------------------------------------------------------------------