├── .env ├── .gitignore ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── Procfile ├── README.md ├── Rakefile ├── Vagrantfile ├── app ├── assets │ ├── images │ │ └── .keep │ ├── javascripts │ │ └── application.js │ └── stylesheets │ │ └── application.scss ├── controllers │ ├── application_controller.rb │ ├── concerns │ │ └── .keep │ └── contacts_controller.rb ├── helpers │ └── application_helper.rb ├── jobs │ └── generate_sample_contacts_job.rb ├── mailers │ └── .keep ├── models │ ├── .keep │ ├── concerns │ │ └── .keep │ └── contact.rb └── views │ ├── contacts │ ├── _form.html.erb │ ├── edit.html.erb │ ├── index.html.erb │ └── new.html.erb │ └── layouts │ └── application.html.erb ├── bin ├── bundle ├── rails ├── rake ├── setup └── spring ├── config.ru ├── config ├── application.rb ├── boot.rb ├── database.yml ├── environment.rb ├── environments │ ├── development.rb │ ├── production.rb │ └── test.rb ├── initializers │ ├── assets.rb │ ├── backtrace_silencers.rb │ ├── cookies_serializer.rb │ ├── filter_parameter_logging.rb │ ├── inflections.rb │ ├── mime_types.rb │ ├── session_store.rb │ └── wrap_parameters.rb ├── locales │ └── en.yml ├── routes.rb └── secrets.yml ├── db ├── migrate │ └── 20150620180716_create_contacts.rb ├── schema.rb └── seeds.rb ├── lib ├── assets │ └── .keep └── tasks │ └── .keep ├── log └── .keep ├── public ├── 404.html ├── 422.html ├── 500.html ├── favicon.ico └── robots.txt ├── test ├── controllers │ └── .keep ├── fixtures │ ├── .keep │ └── contacts.yml ├── helpers │ └── .keep ├── integration │ └── .keep ├── jobs │ └── generate_sample_contacts_job_test.rb ├── mailers │ └── .keep ├── models │ ├── .keep │ └── contact_test.rb └── test_helper.rb └── vendor └── assets ├── javascripts └── .keep └── stylesheets └── .keep /.env: -------------------------------------------------------------------------------- 1 | RVM_WRAPPERS=/home/vagrant/.rvm/wrappers/ruby-2.2.1 2 | -------------------------------------------------------------------------------- /.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 all logfiles and tempfiles. 11 | /log/* 12 | !/log/.keep 13 | /tmp 14 | 15 | # Ignore Vagrant-specific folders 16 | .vagrant 17 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | 4 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 5 | gem 'rails', '4.2.2' 6 | # Use postgresql as the database for Active Record 7 | gem 'pg' 8 | # Use SCSS for stylesheets 9 | gem 'sass-rails', '~> 5.0' 10 | # Use Uglifier as compressor for JavaScript assets 11 | gem 'uglifier', '>= 1.3.0' 12 | # Use CoffeeScript for .coffee assets and views 13 | gem 'coffee-rails', '~> 4.1.0' 14 | # See https://github.com/rails/execjs#readme for more supported runtimes 15 | gem 'therubyracer', platforms: :ruby 16 | 17 | # Use jquery as the JavaScript library 18 | gem 'jquery-rails' 19 | # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks 20 | gem 'turbolinks' 21 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 22 | gem 'jbuilder', '~> 2.0' 23 | # bundle exec rake doc:rails generates the API under doc/api. 24 | gem 'sdoc', '~> 0.4.0', group: :doc 25 | 26 | # Use ActiveModel has_secure_password 27 | # gem 'bcrypt', '~> 3.1.7' 28 | 29 | # Use Unicorn as the app server 30 | # gem 'unicorn' 31 | 32 | # Use Capistrano for deployment 33 | # gem 'capistrano-rails', group: :development 34 | 35 | group :development, :test do 36 | # Call 'byebug' anywhere in the code to stop execution and get a debugger console 37 | gem 'byebug' 38 | 39 | # Access an IRB console on exception pages or by using <%= console %> in views 40 | gem 'web-console', '~> 2.0' 41 | 42 | # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 43 | gem 'spring' 44 | end 45 | 46 | gem 'foreman' 47 | 48 | gem 'bootstrap-sass' 49 | gem 'faker' 50 | gem 'sidekiq' 51 | gem 'sinatra', require: nil 52 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actionmailer (4.2.2) 5 | actionpack (= 4.2.2) 6 | actionview (= 4.2.2) 7 | activejob (= 4.2.2) 8 | mail (~> 2.5, >= 2.5.4) 9 | rails-dom-testing (~> 1.0, >= 1.0.5) 10 | actionpack (4.2.2) 11 | actionview (= 4.2.2) 12 | activesupport (= 4.2.2) 13 | rack (~> 1.6) 14 | rack-test (~> 0.6.2) 15 | rails-dom-testing (~> 1.0, >= 1.0.5) 16 | rails-html-sanitizer (~> 1.0, >= 1.0.1) 17 | actionview (4.2.2) 18 | activesupport (= 4.2.2) 19 | builder (~> 3.1) 20 | erubis (~> 2.7.0) 21 | rails-dom-testing (~> 1.0, >= 1.0.5) 22 | rails-html-sanitizer (~> 1.0, >= 1.0.1) 23 | activejob (4.2.2) 24 | activesupport (= 4.2.2) 25 | globalid (>= 0.3.0) 26 | activemodel (4.2.2) 27 | activesupport (= 4.2.2) 28 | builder (~> 3.1) 29 | activerecord (4.2.2) 30 | activemodel (= 4.2.2) 31 | activesupport (= 4.2.2) 32 | arel (~> 6.0) 33 | activesupport (4.2.2) 34 | i18n (~> 0.7) 35 | json (~> 1.7, >= 1.7.7) 36 | minitest (~> 5.1) 37 | thread_safe (~> 0.3, >= 0.3.4) 38 | tzinfo (~> 1.1) 39 | arel (6.0.0) 40 | autoprefixer-rails (5.2.0.1) 41 | execjs 42 | json 43 | binding_of_caller (0.7.2) 44 | debug_inspector (>= 0.0.1) 45 | bootstrap-sass (3.3.5) 46 | autoprefixer-rails (>= 5.0.0.1) 47 | sass (>= 3.2.19) 48 | builder (3.2.2) 49 | byebug (5.0.0) 50 | columnize (= 0.9.0) 51 | celluloid (0.16.0) 52 | timers (~> 4.0.0) 53 | coffee-rails (4.1.0) 54 | coffee-script (>= 2.2.0) 55 | railties (>= 4.0.0, < 5.0) 56 | coffee-script (2.4.1) 57 | coffee-script-source 58 | execjs 59 | coffee-script-source (1.9.1.1) 60 | columnize (0.9.0) 61 | connection_pool (2.2.0) 62 | debug_inspector (0.0.2) 63 | erubis (2.7.0) 64 | execjs (2.5.2) 65 | faker (1.4.3) 66 | i18n (~> 0.5) 67 | foreman (0.78.0) 68 | thor (~> 0.19.1) 69 | globalid (0.3.5) 70 | activesupport (>= 4.1.0) 71 | hitimes (1.2.2) 72 | i18n (0.7.0) 73 | jbuilder (2.3.0) 74 | activesupport (>= 3.0.0, < 5) 75 | multi_json (~> 1.2) 76 | jquery-rails (4.0.4) 77 | rails-dom-testing (~> 1.0) 78 | railties (>= 4.2.0) 79 | thor (>= 0.14, < 2.0) 80 | json (1.8.3) 81 | libv8 (3.16.14.9) 82 | loofah (2.0.2) 83 | nokogiri (>= 1.5.9) 84 | mail (2.6.3) 85 | mime-types (>= 1.16, < 3) 86 | mime-types (2.6.1) 87 | mini_portile (0.6.2) 88 | minitest (5.7.0) 89 | multi_json (1.11.1) 90 | nokogiri (1.6.6.2) 91 | mini_portile (~> 0.6.0) 92 | pg (0.18.2) 93 | rack (1.6.4) 94 | rack-protection (1.5.3) 95 | rack 96 | rack-test (0.6.3) 97 | rack (>= 1.0) 98 | rails (4.2.2) 99 | actionmailer (= 4.2.2) 100 | actionpack (= 4.2.2) 101 | actionview (= 4.2.2) 102 | activejob (= 4.2.2) 103 | activemodel (= 4.2.2) 104 | activerecord (= 4.2.2) 105 | activesupport (= 4.2.2) 106 | bundler (>= 1.3.0, < 2.0) 107 | railties (= 4.2.2) 108 | sprockets-rails 109 | rails-deprecated_sanitizer (1.0.3) 110 | activesupport (>= 4.2.0.alpha) 111 | rails-dom-testing (1.0.6) 112 | activesupport (>= 4.2.0.beta, < 5.0) 113 | nokogiri (~> 1.6.0) 114 | rails-deprecated_sanitizer (>= 1.0.1) 115 | rails-html-sanitizer (1.0.2) 116 | loofah (~> 2.0) 117 | railties (4.2.2) 118 | actionpack (= 4.2.2) 119 | activesupport (= 4.2.2) 120 | rake (>= 0.8.7) 121 | thor (>= 0.18.1, < 2.0) 122 | rake (10.4.2) 123 | rdoc (4.2.0) 124 | redis (3.2.1) 125 | redis-namespace (1.5.2) 126 | redis (~> 3.0, >= 3.0.4) 127 | ref (1.0.5) 128 | sass (3.4.14) 129 | sass-rails (5.0.3) 130 | railties (>= 4.0.0, < 5.0) 131 | sass (~> 3.1) 132 | sprockets (>= 2.8, < 4.0) 133 | sprockets-rails (>= 2.0, < 4.0) 134 | tilt (~> 1.1) 135 | sdoc (0.4.1) 136 | json (~> 1.7, >= 1.7.7) 137 | rdoc (~> 4.0) 138 | sidekiq (3.4.1) 139 | celluloid (~> 0.16.0) 140 | connection_pool (>= 2.1.1) 141 | json 142 | redis (>= 3.0.6) 143 | redis-namespace (>= 1.3.1) 144 | sinatra (1.4.6) 145 | rack (~> 1.4) 146 | rack-protection (~> 1.4) 147 | tilt (>= 1.3, < 3) 148 | spring (1.3.6) 149 | sprockets (3.2.0) 150 | rack (~> 1.0) 151 | sprockets-rails (2.3.1) 152 | actionpack (>= 3.0) 153 | activesupport (>= 3.0) 154 | sprockets (>= 2.8, < 4.0) 155 | therubyracer (0.12.2) 156 | libv8 (~> 3.16.14.0) 157 | ref 158 | thor (0.19.1) 159 | thread_safe (0.3.5) 160 | tilt (1.4.1) 161 | timers (4.0.1) 162 | hitimes 163 | turbolinks (2.5.3) 164 | coffee-rails 165 | tzinfo (1.2.2) 166 | thread_safe (~> 0.1) 167 | uglifier (2.7.1) 168 | execjs (>= 0.3.0) 169 | json (>= 1.8.0) 170 | web-console (2.1.3) 171 | activemodel (>= 4.0) 172 | binding_of_caller (>= 0.7.2) 173 | railties (>= 4.0) 174 | sprockets-rails (>= 2.0, < 4.0) 175 | 176 | PLATFORMS 177 | ruby 178 | 179 | DEPENDENCIES 180 | bootstrap-sass 181 | byebug 182 | coffee-rails (~> 4.1.0) 183 | faker 184 | foreman 185 | jbuilder (~> 2.0) 186 | jquery-rails 187 | pg 188 | rails (= 4.2.2) 189 | sass-rails (~> 5.0) 190 | sdoc (~> 0.4.0) 191 | sidekiq 192 | sinatra 193 | spring 194 | therubyracer 195 | turbolinks 196 | uglifier (>= 1.3.0) 197 | web-console (~> 2.0) 198 | 199 | BUNDLED WITH 200 | 1.10.5 201 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Tuts+ 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: $RVM_WRAPPERS/bundle exec rails s -b 0.0.0.0 -p 3000 2 | worker: $RVM_WRAPPERS/bundle exec sidekiq 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [Easy Rails Development Environment With Vagrant][published url] 2 | ## Instructor: [Markus Mühlberger][instructor url] 3 | 4 | 5 | When developing a Rails app, you will probably need one or more of these dependencies: a database server, a key-value store, a background worker or a search engine. Installing and running these on your local machine gets messy fast. Data from your app can also interfere with other apps you are developing on the same system. With Vagrant you can isolate these dependencies in a virtual machine, start and stop them at the same time. You can also prevent yourself and others from having to setup everything again when your system crashes or when you move to a new computer. In this course, you will learn how to create a machine with Vagrant, configure it for Rails development and share it with others. 6 | 7 | 8 | ## Source Files Description 9 | 10 | This repository contains the Rails app we are going to use as an example application for this course. It uses PostgreSQL and Redis, as well as Sidekiq for background processing. Of course, there is also a `Vagrantfile` for which defines Vagrant box! 11 | 12 | ------ 13 | 14 | These are source files for the Tuts+ course: [Easy Rails Development Environment With Vagrant][published url] 15 | 16 | Available on [Tuts+](https://tutsplus.com). Teaching skills to millions worldwide. 17 | 18 | [published url]: https://code.tutsplus.com/courses/easy-rails-development-environment-with-vagrant 19 | [instructor url]: https://tutsplus.com/authors/markus-muehlberger 20 | -------------------------------------------------------------------------------- /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 File.expand_path('../config/application', __FILE__) 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # All Vagrant configuration is done below. The "2" in Vagrant.configure 5 | # configures the configuration version (we support older styles for 6 | # backwards compatibility). Please don't change it unless you know what 7 | # you're doing. 8 | Vagrant.configure(2) do |config| 9 | # The most common configuration options are documented and commented below. 10 | # For a complete reference, please see the online documentation at 11 | # https://docs.vagrantup.com. 12 | 13 | # Every Vagrant development environment requires a box. You can search for 14 | # boxes at https://atlas.hashicorp.com/search. 15 | # This line has been updated to point to the "bento/ubuntu-14.04" box instead of "chef/ubuntu-14.04" 16 | config.vm.box = "bento/ubuntu-14.04" 17 | 18 | # Disable automatic box update checking. If you disable this, then 19 | # boxes will only be checked for updates when the user runs 20 | # `vagrant box outdated`. This is not recommended. 21 | # config.vm.box_check_update = false 22 | 23 | # Create a forwarded port mapping which allows access to a specific port 24 | # within the machine from a port on the host machine. In the example below, 25 | # accessing "localhost:8080" will access port 80 on the guest machine. 26 | config.vm.network "forwarded_port", guest: 3000, host: 3000 27 | 28 | # Create a private network, which allows host-only access to the machine 29 | # using a specific IP. 30 | # config.vm.network "private_network", ip: "192.168.33.10" 31 | 32 | # Create a public network, which generally matched to bridged network. 33 | # Bridged networks make the machine appear as another physical device on 34 | # your network. 35 | # config.vm.network "public_network" 36 | 37 | # Share an additional folder to the guest VM. The first argument is 38 | # the path on the host to the actual folder. The second argument is 39 | # the path on the guest to mount the folder. And the optional third 40 | # argument is a set of non-required options. 41 | # config.vm.synced_folder "../data", "/vagrant_data" 42 | 43 | # Provider-specific configuration so you can fine-tune various 44 | # backing providers for Vagrant. These expose provider-specific options. 45 | # Example for VirtualBox: 46 | # 47 | # config.vm.provider "virtualbox" do |vb| 48 | # # Display the VirtualBox GUI when booting the machine 49 | # vb.gui = true 50 | # 51 | # # Customize the amount of memory on the VM: 52 | # vb.memory = "1024" 53 | # end 54 | # 55 | # View the documentation for the provider you are using for more 56 | # information on available options. 57 | 58 | # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies 59 | # such as FTP and Heroku are also available. See the documentation at 60 | # https://docs.vagrantup.com/v2/push/atlas.html for more information. 61 | # config.push.define "atlas" do |push| 62 | # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" 63 | # end 64 | 65 | # Enable provisioning with a shell script. Additional provisioners such as 66 | # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the 67 | # documentation for more information about their specific syntax and use. 68 | config.vm.provision "shell", privileged: false, inline: <<-SHELL 69 | # Install curl and PostgreSQL 70 | sudo apt-get update 71 | sudo apt-get install -y curl postgresql-common postgresql-9.3 libpq-dev 72 | # Create the vagrant db user 73 | sudo su postgres -c "createuser vagrant -s" 74 | # Install RVM, Ruby 2.2 and Bundler 75 | gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 76 | gpg --list-keys D39DC0E3 > /dev/null 77 | if [[ $? != 0 ]]; then curl -sSL https://rvm.io/mpapis.asc | gpg --import - ; fi 78 | curl -sSL https://get.rvm.io | bash -s stable 79 | source /home/vagrant/.profile 80 | rvm install 2.2 81 | gem install bundler --no-ri --no-rdoc 82 | # Compile and install Redis 83 | if [ ! -s "redis-stable.tar.gz" ]; then 84 | curl http://download.redis.io/redis-stable.tar.gz -o redis-stable.tar.gz 85 | tar xzf redis-stable.tar.gz 86 | cd redis-stable 87 | make 88 | sudo make install 89 | # Create folders, copy configuration file and init script 90 | sudo mkdir -p /var/redis/6379 /etc/redis 91 | sudo cp utils/redis_init_script /etc/init.d/redis_6379 92 | sudo update-rc.d redis_6379 defaults 93 | sudo cp redis.conf /etc/redis/6379.conf 94 | # Edit the default configuration file 95 | sudo sed -i 's/daemonize no/daemonize yes/g' /etc/redis/6379.conf 96 | sudo sed -i 's/redis.pid/redis_6379.pid/g' /etc/redis/6379.conf 97 | sudo sed -i 's/# bind 127.0.0.1/bind 127.0.0.1/g' /etc/redis/6379.conf 98 | sudo sed -i 's/logfile ""/logfile \/var\/log\/redis_6379.log/g' /etc/redis/6379.conf 99 | sudo sed -i 's/dir .\//dir \/var\/redis\/6379/g' /etc/redis/6379.conf 100 | # Start Redis 101 | sudo service redis_6379 start 102 | # Cleanup 103 | cd .. 104 | sudo rm -rf redis-stable 105 | fi 106 | # Install bundled gems and create database 107 | cd /vagrant 108 | bundle 109 | rake db:create db:migrate 110 | # Create app init scripts with Foreman 111 | rvmsudo foreman export upstart /etc/init -a rails -u vagrant 112 | sudo service rails start 113 | SHELL 114 | end 115 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tutsplus/easy-rails-development-environment-with-vagrant/c1539f877620f80ff51ee67d99d1f64b537a54ee/app/assets/images/.keep -------------------------------------------------------------------------------- /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, vendor/assets/javascripts, 5 | // or any plugin's 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. 9 | // 10 | // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 11 | // about supported directives. 12 | // 13 | //= require jquery 14 | //= require bootstrap 15 | //= require jquery_ujs 16 | //= require turbolinks 17 | //= require_tree . 18 | -------------------------------------------------------------------------------- /app/assets/stylesheets/application.scss: -------------------------------------------------------------------------------- 1 | @import "bootstrap"; 2 | @import "bootstrap-sprockets"; 3 | 4 | .contact { 5 | margin: 15px 0; 6 | padding: 10px; 7 | border: 1px solid #DDD; 8 | background: #F0F0F0; 9 | 10 | @include clearfix; 11 | 12 | .avatar { 13 | max-width: 80px; 14 | border: 1px solid #CCC; 15 | background: white; 16 | } 17 | 18 | a.edit-link, a.delete-link { 19 | text-align: center; 20 | margin: 10px 0; 21 | } 22 | 23 | .name { 24 | font-size: 18px; 25 | font-weight: bold; 26 | } 27 | 28 | p { 29 | margin-left: 90px; 30 | 31 | &:first-of-type, &:last-child { margin-bottom: 0; } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | # Prevent CSRF attacks by raising an exception. 3 | # For APIs, you may want to use :null_session instead. 4 | protect_from_forgery with: :exception 5 | end 6 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tutsplus/easy-rails-development-environment-with-vagrant/c1539f877620f80ff51ee67d99d1f64b537a54ee/app/controllers/concerns/.keep -------------------------------------------------------------------------------- /app/controllers/contacts_controller.rb: -------------------------------------------------------------------------------- 1 | class ContactsController < ApplicationController 2 | def index 3 | @contacts = Contact.order(:first_name, :last_name) 4 | end 5 | 6 | def new 7 | @contact = Contact.new 8 | end 9 | 10 | def create 11 | @contact = Contact.new(contact_params) 12 | 13 | if @contact.save 14 | redirect_to contacts_path, notice: 'Your contact has been created.' 15 | else 16 | render :new 17 | end 18 | end 19 | 20 | def edit 21 | @contact = Contact.find(params[:id]) 22 | end 23 | 24 | def update 25 | @contact = Contact.find(params[:id]) 26 | 27 | if @contact.update(contact_params) 28 | redirect_to contacts_path, notice: 'Your contact has been updated.' 29 | else 30 | render :edit 31 | end 32 | end 33 | 34 | def destroy 35 | @contact = Contact.find(params[:id]) 36 | 37 | if @contact.destroy 38 | redirect_to contacts_path, notice: 'Your contact has been deleted.' 39 | else 40 | redirect_to contacts_path, alert: 'Your contact couldn\'t be deleted.' 41 | end 42 | end 43 | 44 | def generate 45 | if GenerateSampleContactsJob.perform_later(samples: 5) 46 | redirect_to contacts_path, notice: 'Your request to create sample contacts has been dispatched.' 47 | else 48 | redirect_to contacts_path, alert: 'Your request to create sample contacts has failed to dispatch.' 49 | end 50 | end 51 | 52 | private 53 | 54 | def contact_params 55 | params.require(:contact).permit( 56 | :first_name, :last_name, :street_address, :zip_code, :city, :country_code, :email, :phone_number, :twitter, :avatar_url 57 | ) 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/jobs/generate_sample_contacts_job.rb: -------------------------------------------------------------------------------- 1 | class GenerateSampleContactsJob < ActiveJob::Base 2 | queue_as :default 3 | 4 | def perform(samples: 5) 5 | samples.times do 6 | Contact.create( 7 | first_name: Faker::Name.first_name, 8 | last_name: Faker::Name.last_name, 9 | street_address: Faker::Address.street_address, 10 | zip_code: Faker::Address.zip_code, 11 | city: Faker::Address.city, 12 | country_code: Faker::Address.country_code, 13 | email: Faker::Internet.safe_email, 14 | phone_number: Faker::PhoneNumber.phone_number, 15 | twitter: Faker::Internet.user_name(1..15, %w(_)), 16 | avatar_url: Faker::Avatar.image(nil, '80x80') 17 | ) 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /app/mailers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tutsplus/easy-rails-development-environment-with-vagrant/c1539f877620f80ff51ee67d99d1f64b537a54ee/app/mailers/.keep -------------------------------------------------------------------------------- /app/models/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tutsplus/easy-rails-development-environment-with-vagrant/c1539f877620f80ff51ee67d99d1f64b537a54ee/app/models/.keep -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tutsplus/easy-rails-development-environment-with-vagrant/c1539f877620f80ff51ee67d99d1f64b537a54ee/app/models/concerns/.keep -------------------------------------------------------------------------------- /app/models/contact.rb: -------------------------------------------------------------------------------- 1 | class Contact < ActiveRecord::Base 2 | end 3 | -------------------------------------------------------------------------------- /app/views/contacts/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_for contact do |f| %> 2 |
3 |
4 | <%= f.label :first_name, class: 'control-label' %> 5 | <%= f.text_field :first_name, class: 'form-control' %> 6 |
7 | 8 |
9 | <%= f.label :last_name, class: 'control-label' %> 10 | <%= f.text_field :last_name, class: 'form-control' %> 11 |
12 |
13 | 14 |
15 | <%= f.label :street_address, class: 'control-label' %> 16 | <%= f.text_field :street_address, class: 'form-control' %> 17 |
18 | 19 |
20 |
21 | <%= f.label :country_code, class: 'control-label' %> 22 | <%= f.text_field :country_code, class: 'form-control' %> 23 |
24 | 25 |
26 | <%= f.label :zip_code, class: 'control-label' %> 27 | <%= f.text_field :zip_code, class: 'form-control' %> 28 |
29 | 30 |
31 | <%= f.label :city, class: 'control-label' %> 32 | <%= f.text_field :city, class: 'form-control' %> 33 |
34 |
35 | 36 |
37 |
38 | <%= f.label :phone_number, class: 'control-label' %> 39 | <%= f.text_field :phone_number, class: 'form-control' %> 40 |
41 | 42 |
43 | <%= f.label :email, class: 'control-label' %> 44 | <%= f.text_field :email, class: 'form-control' %> 45 |
46 | 47 |
48 | <%= f.label :twitter, class: 'control-label' %> 49 | <%= f.text_field :twitter, class: 'form-control' %> 50 |
51 |
52 | 53 |
54 | <%= f.label :avatar_url, class: 'control-label' %> 55 | <%= f.url_field :avatar_url, class: 'form-control' %> 56 |
57 | 58 |
59 | <%= f.submit "#{contact.new_record? ? 'Create' : 'Save'} Contact", class: 'btn btn-success' %> 60 | <%= link_to 'Back to Contacts', contacts_path, class: 'btn btn-default' %> 61 |
62 | <% end %> 63 | -------------------------------------------------------------------------------- /app/views/contacts/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Edit Contact

2 | 3 | <%= render partial: 'form', locals: { contact: @contact } %> 4 | -------------------------------------------------------------------------------- /app/views/contacts/index.html.erb: -------------------------------------------------------------------------------- 1 | 2 |
<%= link_to 'New Contact', new_contact_path, class: 'btn btn-success' %>
3 |
<%= link_to 'Generate Sample Contacts', generate_contacts_path, method: :post, class: 'btn btn-info' %>
4 | 5 |
6 | <% if @contacts.size > 0 %> 7 | <% @contacts.each do |contact| %> 8 |
9 |
10 |
11 | <%= image_tag contact.avatar_url, class: 'avatar' %> 12 | <%= link_to 'Edit', edit_contact_path(contact), class: 'btn btn-xs btn-warning edit-link btn-block' %> 13 | <%= link_to 'Delete', contact_path(contact), method: :delete, class: 'btn btn-xs btn-danger delete-link btn-block' %> 14 |
15 |

<%= link_to "#{contact.first_name} #{contact.last_name}", contact, class: 'name' %>

16 |

<%= link_to "@#{contact.twitter}", "https://twitter.com/#{contact.twitter}" %>

17 |

18 | <%= contact.street_address %>
19 | <%= contact.country_code %>-<%= contact.zip_code %>, <%= contact.city %> 20 |

21 | 22 |

23 | Phone: <%= contact.phone_number %>
24 | Email: <%= link_to contact.email, "mailto:#{contact.email}" %> 25 |

26 |
27 |
28 | <% end %> 29 | <% else %> 30 |
31 | There are no contacts yet. <%= link_to 'Create one', new_contact_path %>. 32 | <% end %> 33 |
34 | -------------------------------------------------------------------------------- /app/views/contacts/new.html.erb: -------------------------------------------------------------------------------- 1 |

Create New Contact

2 | 3 | <%= render partial: 'form', locals: { contact: @contact } %> 4 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Contacts 5 | <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> 6 | <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> 7 | <%= csrf_meta_tags %> 8 | 9 | 10 | 11 |
12 |

Contacts

13 |
14 | 15 | <% flash.each do |type, message| %> 16 |
17 | 18 | <%= message %> 19 |
20 | <% end %> 21 | 22 | <%= yield %> 23 | 24 |
25 |

Robots lovingly delivered by Robohash.org.

26 |
27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | APP_PATH = File.expand_path('../../config/application', __FILE__) 7 | require_relative '../config/boot' 8 | require 'rails/commands' 9 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | require_relative '../config/boot' 7 | require 'rake' 8 | Rake.application.run 9 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'pathname' 3 | 4 | # path to your application root. 5 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) 6 | 7 | Dir.chdir APP_ROOT do 8 | # This script is a starting point to setup your application. 9 | # Add necessary setup steps to this file: 10 | 11 | puts "== Installing dependencies ==" 12 | system "gem install bundler --conservative" 13 | system "bundle check || bundle install" 14 | 15 | # puts "\n== Copying sample files ==" 16 | # unless File.exist?("config/database.yml") 17 | # system "cp config/database.yml.sample config/database.yml" 18 | # end 19 | 20 | puts "\n== Preparing database ==" 21 | system "bin/rake db:setup" 22 | 23 | puts "\n== Removing old logs and tempfiles ==" 24 | system "rm -f log/*" 25 | system "rm -rf tmp/cache" 26 | 27 | puts "\n== Restarting application server ==" 28 | system "touch tmp/restart.txt" 29 | end 30 | -------------------------------------------------------------------------------- /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 | if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m) 11 | Gem.paths = { "GEM_PATH" => [Bundler.bundle_path.to_s, *Gem.path].uniq } 12 | gem "spring", match[1] 13 | require "spring/binstub" 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../boot', __FILE__) 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 Contacts 10 | class Application < Rails::Application 11 | # Settings in config/environments/* take precedence over those specified here. 12 | # Application configuration should go into files in config/initializers 13 | # -- all .rb files in that directory are automatically loaded. 14 | 15 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 16 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 17 | # config.time_zone = 'Central Time (US & Canada)' 18 | 19 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 20 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 21 | # config.i18n.default_locale = :de 22 | 23 | # Do not swallow errors in after_commit/after_rollback callbacks. 24 | config.active_record.raise_in_transactional_callbacks = true 25 | 26 | config.active_job.queue_adapter = :sidekiq 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | # PostgreSQL. Versions 8.2 and up are supported. 2 | # 3 | # Install the pg driver: 4 | # gem install pg 5 | # On OS X with Homebrew: 6 | # gem install pg -- --with-pg-config=/usr/local/bin/pg_config 7 | # On OS X with MacPorts: 8 | # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config 9 | # On Windows: 10 | # gem install pg 11 | # Choose the win32 build. 12 | # Install PostgreSQL and put its /bin directory on your path. 13 | # 14 | # Configure Using Gemfile 15 | # gem 'pg' 16 | # 17 | default: &default 18 | adapter: postgresql 19 | encoding: unicode 20 | # For details on connection pooling, see rails configuration guide 21 | # http://guides.rubyonrails.org/configuring.html#database-pooling 22 | pool: 5 23 | 24 | development: 25 | <<: *default 26 | database: contacts_development 27 | 28 | # The specified database role being used to connect to postgres. 29 | # To create additional roles in postgres see `$ createuser --help`. 30 | # When left blank, postgres will use the default role. This is 31 | # the same name as the operating system user that initialized the database. 32 | #username: contacts 33 | 34 | # The password associated with the postgres role (username). 35 | #password: 36 | 37 | # Connect on a TCP socket. Omitted by default since the client uses a 38 | # domain socket that doesn't need configuration. Windows does not have 39 | # domain sockets, so uncomment these lines. 40 | #host: localhost 41 | 42 | # The TCP port the server listens on. Defaults to 5432. 43 | # If your server runs on a different port number, change accordingly. 44 | #port: 5432 45 | 46 | # Schema search path. The server defaults to $user,public 47 | #schema_search_path: myapp,sharedapp,public 48 | 49 | # Minimum log levels, in increasing order: 50 | # debug5, debug4, debug3, debug2, debug1, 51 | # log, notice, warning, error, fatal, and panic 52 | # Defaults to warning. 53 | #min_messages: notice 54 | 55 | # Warning: The database defined as "test" will be erased and 56 | # re-generated from your development database when you run "rake". 57 | # Do not set this db to the same as development or production. 58 | test: 59 | <<: *default 60 | database: contacts_test 61 | 62 | # As with config/secrets.yml, you never want to store sensitive information, 63 | # like your database password, in your source code. If your source code is 64 | # ever seen by anyone, they now have access to your database. 65 | # 66 | # Instead, provide the password as a unix environment variable when you boot 67 | # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database 68 | # for a full rundown on how to provide these environment variables in a 69 | # production deployment. 70 | # 71 | # On Heroku and other platform providers, you may have a full connection URL 72 | # available as an environment variable. For example: 73 | # 74 | # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase" 75 | # 76 | # You can use this database configuration with: 77 | # 78 | # production: 79 | # url: <%= ENV['DATABASE_URL'] %> 80 | # 81 | production: 82 | <<: *default 83 | database: contacts_production 84 | username: contacts 85 | password: <%= ENV['CONTACTS_DATABASE_PASSWORD'] %> 86 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /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 and disable caching. 13 | config.consider_all_requests_local = true 14 | config.action_controller.perform_caching = false 15 | 16 | # Don't care if the mailer can't send. 17 | config.action_mailer.raise_delivery_errors = false 18 | 19 | # Print deprecation notices to the Rails logger. 20 | config.active_support.deprecation = :log 21 | 22 | # Raise an error on page load if there are pending migrations. 23 | config.active_record.migration_error = :page_load 24 | 25 | # Debug mode disables concatenation and preprocessing of assets. 26 | # This option may cause significant delays in view rendering with a large 27 | # number of complex assets. 28 | config.assets.debug = true 29 | 30 | # Asset digests allow you to set far-future HTTP expiration dates on all assets, 31 | # yet still be able to expire them through the digest params. 32 | config.assets.digest = true 33 | 34 | # Adds additional error checking when serving assets at runtime. 35 | # Checks for improperly declared sprockets dependencies. 36 | # Raises helpful error messages. 37 | config.assets.raise_runtime_errors = true 38 | 39 | # Raises error for missing translations 40 | # config.action_view.raise_on_missing_translations = true 41 | end 42 | -------------------------------------------------------------------------------- /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 | # Enable Rack::Cache to put a simple HTTP cache in front of your application 18 | # Add `rack-cache` to your Gemfile before enabling this. 19 | # For large-scale production use, consider using a caching reverse proxy like 20 | # NGINX, varnish or squid. 21 | # config.action_dispatch.rack_cache = true 22 | 23 | # Disable serving static files from the `/public` folder by default since 24 | # Apache or NGINX already handles this. 25 | config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? 26 | 27 | # Compress JavaScripts and CSS. 28 | config.assets.js_compressor = :uglifier 29 | # config.assets.css_compressor = :sass 30 | 31 | # Do not fallback to assets pipeline if a precompiled asset is missed. 32 | config.assets.compile = false 33 | 34 | # Asset digests allow you to set far-future HTTP expiration dates on all assets, 35 | # yet still be able to expire them through the digest params. 36 | config.assets.digest = true 37 | 38 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb 39 | 40 | # Specifies the header that your server uses for sending files. 41 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache 42 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX 43 | 44 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 45 | # config.force_ssl = true 46 | 47 | # Use the lowest log level to ensure availability of diagnostic information 48 | # when problems arise. 49 | config.log_level = :debug 50 | 51 | # Prepend all log lines with the following tags. 52 | # config.log_tags = [ :subdomain, :uuid ] 53 | 54 | # Use a different logger for distributed setups. 55 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) 56 | 57 | # Use a different cache store in production. 58 | # config.cache_store = :mem_cache_store 59 | 60 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 61 | # config.action_controller.asset_host = 'http://assets.example.com' 62 | 63 | # Ignore bad email addresses and do not raise email delivery errors. 64 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 65 | # config.action_mailer.raise_delivery_errors = false 66 | 67 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 68 | # the I18n.default_locale when a translation cannot be found). 69 | config.i18n.fallbacks = true 70 | 71 | # Send deprecation notices to registered listeners. 72 | config.active_support.deprecation = :notify 73 | 74 | # Use default logging formatter so that PID and timestamp are not suppressed. 75 | config.log_formatter = ::Logger::Formatter.new 76 | 77 | # Do not dump schema after migrations. 78 | config.active_record.dump_schema_after_migration = false 79 | end 80 | -------------------------------------------------------------------------------- /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 static file server for tests with Cache-Control for performance. 16 | config.serve_static_files = true 17 | config.static_cache_control = 'public, max-age=3600' 18 | 19 | # Show full error reports and disable caching. 20 | config.consider_all_requests_local = true 21 | config.action_controller.perform_caching = false 22 | 23 | # Raise exceptions instead of rendering exception templates. 24 | config.action_dispatch.show_exceptions = false 25 | 26 | # Disable request forgery protection in test environment. 27 | config.action_controller.allow_forgery_protection = false 28 | 29 | # Tell Action Mailer not to deliver emails to the real world. 30 | # The :test delivery method accumulates sent emails in the 31 | # ActionMailer::Base.deliveries array. 32 | config.action_mailer.delivery_method = :test 33 | 34 | # Randomize the order test cases are executed. 35 | config.active_support.test_order = :random 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 | -------------------------------------------------------------------------------- /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 | 9 | # Precompile additional assets. 10 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. 11 | # Rails.application.config.assets.precompile += %w( search.js ) 12 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.action_dispatch.cookies_serializer = :json 4 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_contacts_session' 4 | -------------------------------------------------------------------------------- /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] if respond_to?(:wrap_parameters) 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 | -------------------------------------------------------------------------------- /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 | # To learn more, please read the Rails Internationalization guide 20 | # available at http://guides.rubyonrails.org/i18n.html. 21 | 22 | en: 23 | hello: "Hello world" 24 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | 2 | Rails.application.routes.draw do 3 | require 'sidekiq/web' 4 | mount Sidekiq::Web => '/sidekiq' 5 | 6 | resources :contacts, except: :show do 7 | post :generate, on: :collection 8 | end 9 | 10 | root 'contacts#index' 11 | end 12 | -------------------------------------------------------------------------------- /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 `rake 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 | development: 14 | secret_key_base: 536023e41cd55c6e9fb2beb98df574bded10d84a2289088cb4dc3f810970793738e1e1e8a08a3e818397ce2f0fbdfe46f4facee7abcede6bc7dcfe49bacfce7f 15 | 16 | test: 17 | secret_key_base: f5798eedbbdf81e5a0265fb19c64ba1e3851b144277774d712e53c97052c412860dc2b621ca99cd97f85bf5935f0181578555a85e1c2e170a342307db510405d 18 | 19 | # Do not keep production secrets in the repository, 20 | # instead read values from the environment. 21 | production: 22 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> 23 | -------------------------------------------------------------------------------- /db/migrate/20150620180716_create_contacts.rb: -------------------------------------------------------------------------------- 1 | class CreateContacts < ActiveRecord::Migration 2 | def change 3 | create_table :contacts do |t| 4 | t.string :first_name 5 | t.string :last_name 6 | t.string :street_address 7 | t.string :zip_code 8 | t.string :city 9 | t.string :country_code 10 | t.string :email 11 | t.string :phone_number 12 | t.string :twitter 13 | t.string :avatar_url 14 | 15 | t.timestamps null: false 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /db/schema.rb: -------------------------------------------------------------------------------- 1 | # encoding: UTF-8 2 | # This file is auto-generated from the current state of the database. Instead 3 | # of editing this file, please use the migrations feature of Active Record to 4 | # incrementally modify your database, and then regenerate this schema definition. 5 | # 6 | # Note that this schema.rb definition is the authoritative source for your 7 | # database schema. If you need to create the application database on another 8 | # system, you should be using db:schema:load, not running all the migrations 9 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations 10 | # you'll amass, the slower it'll run and the greater likelihood for issues). 11 | # 12 | # It's strongly recommended that you check this file into your version control system. 13 | 14 | ActiveRecord::Schema.define(version: 20150620180716) do 15 | 16 | # These are extensions that must be enabled in order to support this database 17 | enable_extension "plpgsql" 18 | 19 | create_table "contacts", force: :cascade do |t| 20 | t.string "first_name" 21 | t.string "last_name" 22 | t.string "street_address" 23 | t.string "zip_code" 24 | t.string "city" 25 | t.string "country_code" 26 | t.string "email" 27 | t.string "phone_number" 28 | t.string "twitter" 29 | t.string "avatar_url" 30 | t.datetime "created_at", null: false 31 | t.datetime "updated_at", null: false 32 | end 33 | 34 | end 35 | -------------------------------------------------------------------------------- /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 rake db:seed (or created alongside the db with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) 7 | # Mayor.create(name: 'Emanuel', city: cities.first) 8 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tutsplus/easy-rails-development-environment-with-vagrant/c1539f877620f80ff51ee67d99d1f64b537a54ee/lib/assets/.keep -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tutsplus/easy-rails-development-environment-with-vagrant/c1539f877620f80ff51ee67d99d1f64b537a54ee/lib/tasks/.keep -------------------------------------------------------------------------------- /log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tutsplus/easy-rails-development-environment-with-vagrant/c1539f877620f80ff51ee67d99d1f64b537a54ee/log/.keep -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tutsplus/easy-rails-development-environment-with-vagrant/c1539f877620f80ff51ee67d99d1f64b537a54ee/public/favicon.ico -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /test/controllers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tutsplus/easy-rails-development-environment-with-vagrant/c1539f877620f80ff51ee67d99d1f64b537a54ee/test/controllers/.keep -------------------------------------------------------------------------------- /test/fixtures/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tutsplus/easy-rails-development-environment-with-vagrant/c1539f877620f80ff51ee67d99d1f64b537a54ee/test/fixtures/.keep -------------------------------------------------------------------------------- /test/fixtures/contacts.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 2 | 3 | one: 4 | first_name: MyString 5 | last_name: MyString 6 | street_address: MyString 7 | zip_code: MyString 8 | city: MyString 9 | country_code: MyString 10 | email: MyString 11 | phone_number: MyString 12 | twitter: MyString 13 | 14 | two: 15 | first_name: MyString 16 | last_name: MyString 17 | street_address: MyString 18 | zip_code: MyString 19 | city: MyString 20 | country_code: MyString 21 | email: MyString 22 | phone_number: MyString 23 | twitter: MyString 24 | -------------------------------------------------------------------------------- /test/helpers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tutsplus/easy-rails-development-environment-with-vagrant/c1539f877620f80ff51ee67d99d1f64b537a54ee/test/helpers/.keep -------------------------------------------------------------------------------- /test/integration/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tutsplus/easy-rails-development-environment-with-vagrant/c1539f877620f80ff51ee67d99d1f64b537a54ee/test/integration/.keep -------------------------------------------------------------------------------- /test/jobs/generate_sample_contacts_job_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class GenerateSampleContactsJobTest < ActiveJob::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /test/mailers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tutsplus/easy-rails-development-environment-with-vagrant/c1539f877620f80ff51ee67d99d1f64b537a54ee/test/mailers/.keep -------------------------------------------------------------------------------- /test/models/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tutsplus/easy-rails-development-environment-with-vagrant/c1539f877620f80ff51ee67d99d1f64b537a54ee/test/models/.keep -------------------------------------------------------------------------------- /test/models/contact_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class ContactTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | ENV['RAILS_ENV'] ||= 'test' 2 | require File.expand_path('../../config/environment', __FILE__) 3 | require 'rails/test_help' 4 | 5 | class ActiveSupport::TestCase 6 | # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. 7 | fixtures :all 8 | 9 | # Add more helper methods to be used by all tests here... 10 | end 11 | -------------------------------------------------------------------------------- /vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tutsplus/easy-rails-development-environment-with-vagrant/c1539f877620f80ff51ee67d99d1f64b537a54ee/vendor/assets/javascripts/.keep -------------------------------------------------------------------------------- /vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tutsplus/easy-rails-development-environment-with-vagrant/c1539f877620f80ff51ee67d99d1f64b537a54ee/vendor/assets/stylesheets/.keep --------------------------------------------------------------------------------