├── .gitignore ├── .rspec ├── Capfile ├── Gemfile ├── Gemfile.lock ├── Guardfile ├── README.md ├── Rakefile ├── app ├── assets │ ├── images │ │ ├── .keep │ │ ├── rails-4-boilerplate.gif │ │ └── ruby-on-rails.jpg │ ├── javascripts │ │ ├── application.js │ │ └── shared.js.coffee │ └── stylesheets │ │ ├── application.scss │ │ ├── dashboard.scss │ │ ├── landing-page.scss │ │ └── shared.scss ├── controllers │ ├── application_controller.rb │ ├── concerns │ │ └── .keep │ ├── omniauth_callbacks_controller.rb │ ├── shared_controller.rb │ └── users_controller.rb ├── helpers │ ├── application_helper.rb │ └── shared_helper.rb ├── mailers │ ├── .keep │ └── admin_mailer.rb ├── models │ ├── .keep │ ├── concerns │ │ └── .keep │ ├── global_config.rb │ ├── identity.rb │ └── user.rb └── views │ ├── admin_mailer │ └── send_support_request.html.erb │ ├── layouts │ ├── _head.html.erb │ ├── application.html.erb │ ├── blank.html.erb │ ├── dashboard.html.erb │ └── partials │ │ └── dashboard │ │ ├── _nav.html.erb │ │ └── _sidebar.html.erb │ ├── shared │ ├── index.html.erb │ └── modals │ │ └── _send_support_request.html.erb │ └── users │ ├── confirmations │ └── new.html.erb │ ├── edit.html.erb │ ├── finish_signup.html.erb │ ├── index.html.erb │ ├── mailer │ ├── confirmation_instructions.html.erb │ ├── reset_password_instructions.html.erb │ └── unlock_instructions.html.erb │ ├── passwords │ ├── edit.html.erb │ └── new.html.erb │ ├── registrations │ ├── edit.html.erb │ └── new.html.erb │ ├── sessions │ └── new.html.erb │ ├── shared │ └── _links.html.erb │ └── unlocks │ └── new.html.erb ├── bin ├── bundle ├── rails ├── rake └── spring ├── config.ru ├── config ├── application.rb ├── boot.rb ├── database.yml ├── deploy.rb ├── deploy │ ├── production.rb │ └── staging.rb ├── environment.rb ├── environments │ ├── development.rb │ ├── production.rb │ └── test.rb ├── global_config.yml ├── initializers │ ├── 01_global_config.rb │ ├── assets.rb │ ├── backtrace_silencers.rb │ ├── cookies_serializer.rb │ ├── devise.rb │ ├── filter_parameter_logging.rb │ ├── inflections.rb │ ├── mime_types.rb │ ├── rails_admin.rb │ ├── secret_token.rb │ ├── session_store.rb │ └── wrap_parameters.rb ├── locales │ ├── devise.en.yml │ └── en.yml └── routes.rb ├── db ├── migrate │ ├── 20150126180608_devise_create_users.rb │ ├── 20150126180704_create_identities.rb │ └── 20150129184051_create_global_configs.rb ├── schema.rb └── seeds.rb ├── lib ├── assets │ └── .keep └── tasks │ └── .keep ├── log └── .keep ├── public ├── 404.html ├── 422.html ├── 500.html ├── favicon.ico └── robots.txt ├── spec ├── controllers │ ├── shared_controller_spec.rb │ └── users_controller_spec.rb ├── factories │ ├── global_configs.rb │ ├── identities.rb │ └── users.rb ├── mailers │ └── admin_mailer_spec.rb ├── models │ ├── global_config_spec.rb │ ├── identity_spec.rb │ └── user_spec.rb ├── rails_helper.rb └── spec_helper.rb ├── test ├── controllers │ └── .keep ├── fixtures │ └── .keep ├── helpers │ └── .keep ├── integration │ └── .keep ├── mailers │ └── .keep ├── models │ └── .keep └── test_helper.rb └── vendor └── assets ├── javascripts └── .keep └── stylesheets └── .keep /.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/*.log 16 | /tmp 17 | 18 | # Ignore env vars 19 | /.env -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --require spec_helper 3 | --format documentation -------------------------------------------------------------------------------- /Capfile: -------------------------------------------------------------------------------- 1 | # Load DSL and set up stages 2 | require 'capistrano/setup' 3 | 4 | # Include default deployment tasks 5 | require 'capistrano/deploy' 6 | 7 | # Include tasks from other gems included in your Gemfile 8 | # 9 | # For documentation on these, see for example: 10 | # 11 | # https://github.com/capistrano/rbenv 12 | # https://github.com/capistrano/chruby 13 | # https://github.com/capistrano/rails 14 | # https://github.com/capistrano/passenger 15 | # 16 | require 'capistrano/rvm' 17 | require 'capistrano/bundler' 18 | require 'capistrano/rails' 19 | require 'capistrano/rails/assets' 20 | require 'capistrano/rails/migrations' 21 | require 'whenever/capistrano' 22 | require 'capistrano/puma' 23 | require 'slackistrano/capistrano' 24 | 25 | # require 'slack-poster' 26 | 27 | # Load custom tasks from `lib/capistrano/tasks' if you have any defined 28 | Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } 29 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | ruby '2.3.1' 3 | 4 | # ======================= 5 | # CONFIG 6 | # ======================= 7 | 8 | # Load ENV variables 9 | gem 'dotenv-rails', '>= 2.0.0', require: 'dotenv/rails-now' 10 | 11 | # ======================= 12 | # RAILS CORE 13 | # ======================= 14 | 15 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 16 | gem 'rails', '4.2.6' 17 | # Use postgresql as the database for Active Record 18 | gem 'pg', '0.18.2' 19 | # bundle exec rake doc:rails generates the API under doc/api. 20 | gem 'sdoc', '~> 0.4.1', group: :doc 21 | # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 22 | gem 'spring', '>= 1.3.6', group: :development 23 | # Makes running Rails easier - based on 12factor.net 24 | gem 'rails_12factor', '>= 0.0.3', group: :production 25 | # webserver 26 | gem 'puma' 27 | 28 | # ======================= 29 | # API 30 | # ======================= 31 | 32 | # CORS managment for api access via js 33 | gem 'rack-cors', require: 'rack/cors' 34 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 35 | gem 'jbuilder', '>= 2.3.0' 36 | # API for Ember apps 37 | gem 'active_model_serializers', '>=0.9.3' 38 | # Pagination 39 | gem 'kaminari', '0.16.3' 40 | # Search Queries 41 | # gem 'ransack', github: 'activerecord-hackery/ransack' 42 | gem 'ransack', '1.7.0' 43 | # http request library 44 | gem 'httparty', '>= 0.13.7' 45 | 46 | # ======================= 47 | # AUTH & SOCIAL LOGINS 48 | # ======================= 49 | 50 | # The Core Rails Authentication system 51 | gem 'devise' 52 | # Standardized auth system 53 | gem 'omniauth' 54 | # Twitter for omniauth 55 | gem 'omniauth-twitter' 56 | # Facebook for omniauth 57 | gem 'omniauth-facebook' 58 | # Linkedin for omniauth 59 | gem 'omniauth-linkedin' 60 | 61 | # ======================= 62 | # ADMIN 63 | # ======================= 64 | 65 | # Core Admin Panel 66 | gem 'rails_admin', '~> 0.8.0' 67 | # Slack Support For Notifications 68 | gem 'slack-poster' 69 | 70 | # ======================= 71 | # UI GEMS 72 | # ======================= 73 | 74 | # Use jquery as the JavaScript library 75 | gem 'jquery-rails', '>= 4.0.3' 76 | # Jquery UI 77 | gem 'jquery-ui-rails' 78 | # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks 79 | gem 'turbolinks', '>= 2.5.3' 80 | # Make jquery on DOM ready work with turbolinks 81 | gem 'jquery-turbolinks', '>= 2.1.0' 82 | # Use Bootstrap Offical Sass Port 83 | gem 'bootstrap-sass', '~> 3.3.0' 84 | # Use FontAwesome Offical Sass Port 85 | gem 'font-awesome-sass', '~> 4.5.0' 86 | # Use SCSS for stylesheets 87 | gem 'sass-rails', '~> 5.0.0' 88 | # Use Uglifier as compressor for JavaScript assets 89 | gem 'uglifier', '~> 2.7.0' 90 | # Use CoffeeScript for .js.coffee assets and views 91 | gem 'coffee-rails', '~> 4.1.0' 92 | # Compress css to inline styles for HTML emails 93 | gem 'roadie-rails' 94 | 95 | # ======================= 96 | # TESTING 97 | # ======================= 98 | 99 | group :development, :test do 100 | # Test Framework we are using 101 | gem 'rspec-rails', '>= 3.2.1' 102 | # Spring for faster gaurd test loading 103 | gem 'spring-commands-rspec', '>= 1.0.4' 104 | # Fixtures replacement 105 | gem 'factory_girl_rails', '>= 4.5.0' 106 | 107 | gem 'rspec-collection_matchers', '>= 1.1.2' 108 | # Fake data generator 109 | gem 'faker', '>= 1.6.1' 110 | # Simulate User Interactions 111 | gem 'capybara', '>= 2.4.4' 112 | # Easily reset db between tests 113 | gem 'database_cleaner', '>= 1.4.1' 114 | # Open web browser from test suite 115 | gem 'launchy', '>= 2.4.3' 116 | # Test JS browser interactions 117 | gem 'selenium-webdriver', '>= 2.45.0' 118 | # Ruby cops 119 | gem 'rubocop', '~> 0.40.0', require: false 120 | # Ruboco for Rspec 121 | gem 'rubocop-rspec' 122 | # Rubocop for guard 123 | gem 'guard-rubocop' 124 | end 125 | 126 | group :test do 127 | # Better matchers for Rspec 128 | gem 'shoulda-matchers', '~> 3.0' 129 | # Code Coverage 130 | gem 'simplecov' 131 | gem 'simplecov-rcov' 132 | # Reporting for Jenkins 133 | gem 'ci_reporter' 134 | # Rspec Reporting for Jenkins 135 | gem 'ci_reporter_rspec' 136 | end 137 | 138 | # ======================= 139 | # DEPLOYMENT 140 | # ======================= 141 | 142 | group :development do 143 | gem 'capistrano-harrow', git: 'https://github.com/harrowio/capistrano-harrow', tag: '0.3.1' 144 | gem 'capistrano', '>= 3.4.0' 145 | gem 'capistrano-rails', '>= 1.1.2' 146 | gem 'capistrano-bundler', '>= 1.1' 147 | gem 'capistrano-rvm', '>= 0.1.2' 148 | gem 'capistrano-touch-linked-files', '>= 0.2.1' 149 | gem 'capistrano3-puma', github: 'seuros/capistrano-puma' 150 | gem 'slackistrano', '>= 3.0.1', require: false 151 | end 152 | 153 | # ======================= 154 | # LIVE RELOAD FOR DEVELOPMENT 155 | # ======================= 156 | 157 | group :development do 158 | gem 'guard', '>= 2.12.5', require: false 159 | gem 'guard-livereload', '>= 2.5.2', require: false 160 | # Watch test files and run on save, start it with: guard init rspec 161 | gem 'guard-rspec', '>= 4.6.5', require: false 162 | gem 'rack-livereload', '>= 0.3.15' 163 | gem 'rb-fsevent', '>= 0.9.4', require: false 164 | end 165 | 166 | # ======================= 167 | # INACTIVE DEFAULTS 168 | # ======================= 169 | 170 | # See https://github.com/sstephenson/execjs#readme for more supported runtimes 171 | # gem 'therubyracer', platforms: :ruby 172 | 173 | # Use ActiveModel has_secure_password 174 | # gem 'bcrypt', '~> 3.1.7' 175 | 176 | # Use unicorn as the app server 177 | # gem 'unicorn' 178 | 179 | # Use debugger 180 | # gem 'debugger', group: [:development, :test] 181 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GIT 2 | remote: git://github.com/seuros/capistrano-puma.git 3 | revision: 963e8f946681d7c4c7bcbeb948abebdb5a15e978 4 | specs: 5 | capistrano3-puma (2.0.0) 6 | capistrano (~> 3.5) 7 | capistrano-bundler 8 | puma (~> 3.4) 9 | 10 | GIT 11 | remote: https://github.com/harrowio/capistrano-harrow 12 | revision: b71faa62788407242ee65eb045d100c7a7f8bf10 13 | tag: 0.3.1 14 | specs: 15 | capistrano-harrow (0.3.1) 16 | 17 | GEM 18 | remote: https://rubygems.org/ 19 | specs: 20 | actionmailer (4.2.6) 21 | actionpack (= 4.2.6) 22 | actionview (= 4.2.6) 23 | activejob (= 4.2.6) 24 | mail (~> 2.5, >= 2.5.4) 25 | rails-dom-testing (~> 1.0, >= 1.0.5) 26 | actionpack (4.2.6) 27 | actionview (= 4.2.6) 28 | activesupport (= 4.2.6) 29 | rack (~> 1.6) 30 | rack-test (~> 0.6.2) 31 | rails-dom-testing (~> 1.0, >= 1.0.5) 32 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 33 | actionview (4.2.6) 34 | activesupport (= 4.2.6) 35 | builder (~> 3.1) 36 | erubis (~> 2.7.0) 37 | rails-dom-testing (~> 1.0, >= 1.0.5) 38 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 39 | active_model_serializers (0.10.0) 40 | actionpack (>= 4.0) 41 | activemodel (>= 4.0) 42 | railties (>= 4.0) 43 | activejob (4.2.6) 44 | activesupport (= 4.2.6) 45 | globalid (>= 0.3.0) 46 | activemodel (4.2.6) 47 | activesupport (= 4.2.6) 48 | builder (~> 3.1) 49 | activerecord (4.2.6) 50 | activemodel (= 4.2.6) 51 | activesupport (= 4.2.6) 52 | arel (~> 6.0) 53 | activesupport (4.2.6) 54 | i18n (~> 0.7) 55 | json (~> 1.7, >= 1.7.7) 56 | minitest (~> 5.1) 57 | thread_safe (~> 0.3, >= 0.3.4) 58 | tzinfo (~> 1.1) 59 | addressable (2.4.0) 60 | airbrussh (1.0.2) 61 | sshkit (>= 1.6.1, != 1.7.0) 62 | arel (6.0.3) 63 | ast (2.2.0) 64 | autoprefixer-rails (6.3.6.1) 65 | execjs 66 | bcrypt (3.1.11) 67 | bootstrap-sass (3.3.6) 68 | autoprefixer-rails (>= 5.2.1) 69 | sass (>= 3.3.4) 70 | builder (3.2.2) 71 | capistrano (3.5.0) 72 | airbrussh (>= 1.0.0) 73 | capistrano-harrow 74 | i18n 75 | rake (>= 10.0.0) 76 | sshkit (>= 1.9.0) 77 | capistrano-bundler (1.1.4) 78 | capistrano (~> 3.1) 79 | sshkit (~> 1.2) 80 | capistrano-rails (1.1.6) 81 | capistrano (~> 3.1) 82 | capistrano-bundler (~> 1.1) 83 | capistrano-rvm (0.1.2) 84 | capistrano (~> 3.0) 85 | sshkit (~> 1.2) 86 | capistrano-touch-linked-files (0.3.0) 87 | capistrano (>= 3.0) 88 | capybara (2.7.1) 89 | addressable 90 | mime-types (>= 1.16) 91 | nokogiri (>= 1.3.3) 92 | rack (>= 1.0.0) 93 | rack-test (>= 0.5.4) 94 | xpath (~> 2.0) 95 | childprocess (0.5.9) 96 | ffi (~> 1.0, >= 1.0.11) 97 | ci_reporter (2.0.0) 98 | builder (>= 2.1.2) 99 | ci_reporter_rspec (1.0.0) 100 | ci_reporter (~> 2.0) 101 | rspec (>= 2.14, < 4) 102 | coderay (1.1.1) 103 | coffee-rails (4.1.1) 104 | coffee-script (>= 2.2.0) 105 | railties (>= 4.0.0, < 5.1.x) 106 | coffee-script (2.4.1) 107 | coffee-script-source 108 | execjs 109 | coffee-script-source (1.10.0) 110 | concurrent-ruby (1.0.2) 111 | css_parser (1.3.7) 112 | addressable 113 | database_cleaner (1.5.3) 114 | devise (4.1.1) 115 | bcrypt (~> 3.0) 116 | orm_adapter (~> 0.1) 117 | railties (>= 4.1.0, < 5.1) 118 | responders 119 | warden (~> 1.2.3) 120 | diff-lcs (1.2.5) 121 | docile (1.1.5) 122 | dotenv (2.1.1) 123 | dotenv-rails (2.1.1) 124 | dotenv (= 2.1.1) 125 | railties (>= 4.0, < 5.1) 126 | em-websocket (0.5.1) 127 | eventmachine (>= 0.12.9) 128 | http_parser.rb (~> 0.6.0) 129 | erubis (2.7.0) 130 | eventmachine (1.2.0.1) 131 | execjs (2.7.0) 132 | factory_girl (4.7.0) 133 | activesupport (>= 3.0.0) 134 | factory_girl_rails (4.7.0) 135 | factory_girl (~> 4.7.0) 136 | railties (>= 3.0.0) 137 | faker (1.6.3) 138 | i18n (~> 0.5) 139 | faraday (0.9.2) 140 | multipart-post (>= 1.2, < 3) 141 | ffi (1.9.10) 142 | font-awesome-rails (4.6.3.0) 143 | railties (>= 3.2, < 5.1) 144 | font-awesome-sass (4.5.0) 145 | sass (>= 3.2) 146 | formatador (0.2.5) 147 | globalid (0.3.6) 148 | activesupport (>= 4.1.0) 149 | guard (2.14.0) 150 | formatador (>= 0.2.4) 151 | listen (>= 2.7, < 4.0) 152 | lumberjack (~> 1.0) 153 | nenv (~> 0.1) 154 | notiffany (~> 0.0) 155 | pry (>= 0.9.12) 156 | shellany (~> 0.0) 157 | thor (>= 0.18.1) 158 | guard-compat (1.2.1) 159 | guard-livereload (2.5.2) 160 | em-websocket (~> 0.5) 161 | guard (~> 2.8) 162 | guard-compat (~> 1.0) 163 | multi_json (~> 1.8) 164 | guard-rspec (4.7.0) 165 | guard (~> 2.1) 166 | guard-compat (~> 1.1) 167 | rspec (>= 2.99.0, < 4.0) 168 | guard-rubocop (1.2.0) 169 | guard (~> 2.0) 170 | rubocop (~> 0.20) 171 | haml (4.0.7) 172 | tilt 173 | hashie (3.4.4) 174 | http_parser.rb (0.6.0) 175 | httparty (0.13.7) 176 | json (~> 1.8) 177 | multi_xml (>= 0.5.2) 178 | i18n (0.7.0) 179 | jbuilder (2.4.1) 180 | activesupport (>= 3.0.0, < 5.1) 181 | multi_json (~> 1.2) 182 | jquery-rails (4.1.1) 183 | rails-dom-testing (>= 1, < 3) 184 | railties (>= 4.2.0) 185 | thor (>= 0.14, < 2.0) 186 | jquery-turbolinks (2.1.0) 187 | railties (>= 3.1.0) 188 | turbolinks 189 | jquery-ui-rails (5.0.5) 190 | railties (>= 3.2.16) 191 | json (1.8.3) 192 | jwt (1.5.1) 193 | kaminari (0.16.3) 194 | actionpack (>= 3.0.0) 195 | activesupport (>= 3.0.0) 196 | launchy (2.4.3) 197 | addressable (~> 2.3) 198 | listen (3.1.5) 199 | rb-fsevent (~> 0.9, >= 0.9.4) 200 | rb-inotify (~> 0.9, >= 0.9.7) 201 | ruby_dep (~> 1.2) 202 | loofah (2.0.3) 203 | nokogiri (>= 1.5.9) 204 | lumberjack (1.0.10) 205 | mail (2.6.4) 206 | mime-types (>= 1.16, < 4) 207 | method_source (0.8.2) 208 | mime-types (3.1) 209 | mime-types-data (~> 3.2015) 210 | mime-types-data (3.2016.0521) 211 | mini_portile2 (2.0.0) 212 | minitest (5.9.0) 213 | multi_json (1.12.1) 214 | multi_xml (0.5.5) 215 | multipart-post (2.0.0) 216 | nenv (0.3.0) 217 | nested_form (0.3.2) 218 | net-scp (1.2.1) 219 | net-ssh (>= 2.6.5) 220 | net-ssh (3.1.1) 221 | nokogiri (1.6.7.2) 222 | mini_portile2 (~> 2.0.0.rc2) 223 | notiffany (0.1.0) 224 | nenv (~> 0.1) 225 | shellany (~> 0.0) 226 | oauth (0.5.1) 227 | oauth2 (1.1.0) 228 | faraday (>= 0.8, < 0.10) 229 | jwt (~> 1.0, < 1.5.2) 230 | multi_json (~> 1.3) 231 | multi_xml (~> 0.5) 232 | rack (>= 1.2, < 3) 233 | omniauth (1.3.1) 234 | hashie (>= 1.2, < 4) 235 | rack (>= 1.0, < 3) 236 | omniauth-facebook (3.0.0) 237 | omniauth-oauth2 (~> 1.2) 238 | omniauth-linkedin (0.2.0) 239 | omniauth-oauth (~> 1.0) 240 | omniauth-oauth (1.1.0) 241 | oauth 242 | omniauth (~> 1.0) 243 | omniauth-oauth2 (1.4.0) 244 | oauth2 (~> 1.0) 245 | omniauth (~> 1.2) 246 | omniauth-twitter (1.2.1) 247 | json (~> 1.3) 248 | omniauth-oauth (~> 1.1) 249 | orm_adapter (0.5.0) 250 | parser (2.3.1.0) 251 | ast (~> 2.2) 252 | pg (0.18.2) 253 | polyamorous (1.3.0) 254 | activerecord (>= 3.0) 255 | powerpack (0.1.1) 256 | pry (0.10.3) 257 | coderay (~> 1.1.0) 258 | method_source (~> 0.8.1) 259 | slop (~> 3.4) 260 | puma (3.4.0) 261 | rack (1.6.4) 262 | rack-cors (0.4.0) 263 | rack-livereload (0.3.16) 264 | rack 265 | rack-pjax (0.8.0) 266 | nokogiri (~> 1.5) 267 | rack (~> 1.1) 268 | rack-test (0.6.3) 269 | rack (>= 1.0) 270 | rails (4.2.6) 271 | actionmailer (= 4.2.6) 272 | actionpack (= 4.2.6) 273 | actionview (= 4.2.6) 274 | activejob (= 4.2.6) 275 | activemodel (= 4.2.6) 276 | activerecord (= 4.2.6) 277 | activesupport (= 4.2.6) 278 | bundler (>= 1.3.0, < 2.0) 279 | railties (= 4.2.6) 280 | sprockets-rails 281 | rails-deprecated_sanitizer (1.0.3) 282 | activesupport (>= 4.2.0.alpha) 283 | rails-dom-testing (1.0.7) 284 | activesupport (>= 4.2.0.beta, < 5.0) 285 | nokogiri (~> 1.6.0) 286 | rails-deprecated_sanitizer (>= 1.0.1) 287 | rails-html-sanitizer (1.0.3) 288 | loofah (~> 2.0) 289 | rails_12factor (0.0.3) 290 | rails_serve_static_assets 291 | rails_stdout_logging 292 | rails_admin (0.8.1) 293 | builder (~> 3.1) 294 | coffee-rails (~> 4.0) 295 | font-awesome-rails (>= 3.0, < 5) 296 | haml (~> 4.0) 297 | jquery-rails (>= 3.0, < 5) 298 | jquery-ui-rails (~> 5.0) 299 | kaminari (~> 0.14) 300 | nested_form (~> 0.3) 301 | rack-pjax (~> 0.7) 302 | rails (~> 4.0) 303 | remotipart (~> 1.0) 304 | safe_yaml (~> 1.0) 305 | sass-rails (>= 4.0, < 6) 306 | rails_serve_static_assets (0.0.5) 307 | rails_stdout_logging (0.0.5) 308 | railties (4.2.6) 309 | actionpack (= 4.2.6) 310 | activesupport (= 4.2.6) 311 | rake (>= 0.8.7) 312 | thor (>= 0.18.1, < 2.0) 313 | rainbow (2.1.0) 314 | rake (11.1.2) 315 | ransack (1.7.0) 316 | actionpack (>= 3.0) 317 | activerecord (>= 3.0) 318 | activesupport (>= 3.0) 319 | i18n 320 | polyamorous (~> 1.2) 321 | rb-fsevent (0.9.7) 322 | rb-inotify (0.9.7) 323 | ffi (>= 0.5.0) 324 | rdoc (4.2.2) 325 | json (~> 1.4) 326 | remotipart (1.2.1) 327 | responders (2.2.0) 328 | railties (>= 4.2.0, < 5.1) 329 | roadie (3.1.1) 330 | css_parser (~> 1.3.4) 331 | nokogiri (>= 1.5.0, < 1.7.0) 332 | roadie-rails (1.1.1) 333 | railties (>= 3.0, < 5.1) 334 | roadie (~> 3.1) 335 | rspec (3.4.0) 336 | rspec-core (~> 3.4.0) 337 | rspec-expectations (~> 3.4.0) 338 | rspec-mocks (~> 3.4.0) 339 | rspec-collection_matchers (1.1.2) 340 | rspec-expectations (>= 2.99.0.beta1) 341 | rspec-core (3.4.4) 342 | rspec-support (~> 3.4.0) 343 | rspec-expectations (3.4.0) 344 | diff-lcs (>= 1.2.0, < 2.0) 345 | rspec-support (~> 3.4.0) 346 | rspec-mocks (3.4.1) 347 | diff-lcs (>= 1.2.0, < 2.0) 348 | rspec-support (~> 3.4.0) 349 | rspec-rails (3.4.2) 350 | actionpack (>= 3.0, < 4.3) 351 | activesupport (>= 3.0, < 4.3) 352 | railties (>= 3.0, < 4.3) 353 | rspec-core (~> 3.4.0) 354 | rspec-expectations (~> 3.4.0) 355 | rspec-mocks (~> 3.4.0) 356 | rspec-support (~> 3.4.0) 357 | rspec-support (3.4.1) 358 | rubocop (0.40.0) 359 | parser (>= 2.3.1.0, < 3.0) 360 | powerpack (~> 0.1) 361 | rainbow (>= 1.99.1, < 3.0) 362 | ruby-progressbar (~> 1.7) 363 | unicode-display_width (~> 1.0, >= 1.0.1) 364 | rubocop-rspec (1.5.0) 365 | rubocop (>= 0.40.0) 366 | ruby-progressbar (1.8.1) 367 | ruby_dep (1.3.1) 368 | rubyzip (1.2.0) 369 | safe_yaml (1.0.4) 370 | sass (3.4.22) 371 | sass-rails (5.0.4) 372 | railties (>= 4.0.0, < 5.0) 373 | sass (~> 3.1) 374 | sprockets (>= 2.8, < 4.0) 375 | sprockets-rails (>= 2.0, < 4.0) 376 | tilt (>= 1.1, < 3) 377 | sdoc (0.4.1) 378 | json (~> 1.7, >= 1.7.7) 379 | rdoc (~> 4.0) 380 | selenium-webdriver (2.53.0) 381 | childprocess (~> 0.5) 382 | rubyzip (~> 1.0) 383 | websocket (~> 1.0) 384 | shellany (0.0.1) 385 | shoulda-matchers (3.1.1) 386 | activesupport (>= 4.0.0) 387 | simplecov (0.11.2) 388 | docile (~> 1.1.0) 389 | json (~> 1.8) 390 | simplecov-html (~> 0.10.0) 391 | simplecov-html (0.10.0) 392 | simplecov-rcov (0.2.3) 393 | simplecov (>= 0.4.1) 394 | slack-poster (2.2.0) 395 | faraday (~> 0.9.2) 396 | slackistrano (3.0.1) 397 | capistrano (>= 3.5.0) 398 | json 399 | slop (3.6.0) 400 | spring (1.7.1) 401 | spring-commands-rspec (1.0.4) 402 | spring (>= 0.9.1) 403 | sprockets (3.6.0) 404 | concurrent-ruby (~> 1.0) 405 | rack (> 1, < 3) 406 | sprockets-rails (3.0.4) 407 | actionpack (>= 4.0) 408 | activesupport (>= 4.0) 409 | sprockets (>= 3.0.0) 410 | sshkit (1.10.0) 411 | net-scp (>= 1.1.2) 412 | net-ssh (>= 2.8.0) 413 | thor (0.19.1) 414 | thread_safe (0.3.5) 415 | tilt (2.0.4) 416 | turbolinks (2.5.3) 417 | coffee-rails 418 | tzinfo (1.2.2) 419 | thread_safe (~> 0.1) 420 | uglifier (2.7.2) 421 | execjs (>= 0.3.0) 422 | json (>= 1.8.0) 423 | unicode-display_width (1.0.5) 424 | warden (1.2.6) 425 | rack (>= 1.0) 426 | websocket (1.2.3) 427 | xpath (2.0.0) 428 | nokogiri (~> 1.3) 429 | 430 | PLATFORMS 431 | ruby 432 | 433 | DEPENDENCIES 434 | active_model_serializers (>= 0.9.3) 435 | bootstrap-sass (~> 3.3.0) 436 | capistrano (>= 3.4.0) 437 | capistrano-bundler (>= 1.1) 438 | capistrano-harrow! 439 | capistrano-rails (>= 1.1.2) 440 | capistrano-rvm (>= 0.1.2) 441 | capistrano-touch-linked-files (>= 0.2.1) 442 | capistrano3-puma! 443 | capybara (>= 2.4.4) 444 | ci_reporter 445 | ci_reporter_rspec 446 | coffee-rails (~> 4.1.0) 447 | database_cleaner (>= 1.4.1) 448 | devise 449 | dotenv-rails (>= 2.0.0) 450 | factory_girl_rails (>= 4.5.0) 451 | faker (>= 1.6.1) 452 | font-awesome-sass (~> 4.5.0) 453 | guard (>= 2.12.5) 454 | guard-livereload (>= 2.5.2) 455 | guard-rspec (>= 4.6.5) 456 | guard-rubocop 457 | httparty (>= 0.13.7) 458 | jbuilder (>= 2.3.0) 459 | jquery-rails (>= 4.0.3) 460 | jquery-turbolinks (>= 2.1.0) 461 | jquery-ui-rails 462 | kaminari (= 0.16.3) 463 | launchy (>= 2.4.3) 464 | omniauth 465 | omniauth-facebook 466 | omniauth-linkedin 467 | omniauth-twitter 468 | pg (= 0.18.2) 469 | puma 470 | rack-cors 471 | rack-livereload (>= 0.3.15) 472 | rails (= 4.2.6) 473 | rails_12factor (>= 0.0.3) 474 | rails_admin (~> 0.8.0) 475 | ransack (= 1.7.0) 476 | rb-fsevent (>= 0.9.4) 477 | roadie-rails 478 | rspec-collection_matchers (>= 1.1.2) 479 | rspec-rails (>= 3.2.1) 480 | rubocop (~> 0.40.0) 481 | rubocop-rspec 482 | sass-rails (~> 5.0.0) 483 | sdoc (~> 0.4.1) 484 | selenium-webdriver (>= 2.45.0) 485 | shoulda-matchers (~> 3.0) 486 | simplecov 487 | simplecov-rcov 488 | slack-poster 489 | slackistrano (>= 3.0.1) 490 | spring (>= 1.3.6) 491 | spring-commands-rspec (>= 1.0.4) 492 | turbolinks (>= 2.5.3) 493 | uglifier (~> 2.7.0) 494 | 495 | RUBY VERSION 496 | ruby 2.3.1p112 497 | 498 | BUNDLED WITH 499 | 1.12.3 500 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rails 4 Boilerplate 2 | 3 | ![Rails Banner](https://raw.githubusercontent.com/TristanToye/rails-4-boilerplate/master/app/assets/images/ruby-on-rails.jpg "Rails 4 Boilerplate") 4 | 5 | **UPDATED:** I have moved this project for Rails 5, 6 & beyond here: https://github.com/TristanToye/rails-template 6 | 7 | This is a starting point for a simple user app in rails. This core set of gems requires very little config to get up and running. The goal was to make this as simple as possible. Config all in one file, out of the box ready to rock user based app. 8 | 9 | A demo can be found here, it may take a second to load: [https://rails-4-boilerplate.herokuapp.com/](https://rails-4-boilerplate.herokuapp.com/) 10 | 11 | ## What is included in this boilerplate: 12 | * [Rails 4](https://github.com/rails/rails) 13 | * [Devise](https://github.com/plataformatec/devise) - Users setup & ready to go 14 | * [Omniauth Multiauth](https://github.com/intridea/omniauth) - Facbook, Twitter, & Linkedin ready to rock 15 | * Email SMTP - simple config with [Mandrill](https://mandrillapp.com) 16 | * [Slack Notifications](https://github.com/rikas/slack-poster) 17 | * Basic Support Form - email & Slack notifications for multiple teams 18 | * [Rails Admin](https://github.com/sferik/rails_admin) - out of the box admin UI 19 | * [Bootstrap Sass](https://github.com/twbs/bootstrap-sass) 20 | * [FontAwesome Sass](https://github.com/FortAwesome/font-awesome-sass) 21 | * [Rspec Test Suite](https://github.com/rspec/rspec) (Factory Girl, Capybara, Faker, etc.) 22 | * [Capistrano](https://github.com/capistrano/capistrano) - automated deployment 23 | * [Guard-Livereload](https://github.com/guard/guard-livereload) - Browser Reloading in Dev 24 | * [Check the Gemfile for more!](https://github.com/TristanToye/rails-4-boilerplate/blob/master/Gemfile) 25 | 26 | ![Features Gif](https://raw.githubusercontent.com/TristanToye/rails-4-boilerplate/master/app/assets/images/rails-4-boilerplate.gif "Rails 4 Boilerplate Features") 27 | 28 | ## How do I set this up? 29 | 30 | Clone the repo to your local machine and cd: 31 | 32 | ```html 33 | git clone https://github.com/TristanToye/rails-4-boilerplate.git 34 | cd rails-4-boilerplate 35 | ``` 36 | 37 | Run `bundle install` to install all the gems we are using. 38 | 39 | [Configure your local database connection](#database_config) 40 | 41 | You can now run the app as normal: `rails s` 42 | 43 | However, to use everything properly we need to set some environment variables & configuration for various services. 44 | 45 | ### Configuration 46 | 47 | Locally we are using [dotenv](https://github.com/bkeepers/dotenv) for our secret keys, which allows us to load all the environment varibles we are using for most config functions in one file - making it easy to keep track of. You can use this in production as well, but make sure you gitignore the local file (it is in gitignore by default for this boilerplate). 48 | 49 | Create a `.env` file in the root of the repo, we will use this to save our environment variables as we go through config. 50 | 51 | For non-secret config we are using a YAML file found in `config/global_config.yml` - this file is used to set basic global constants that are used throughout the app. I will walk you through each part to keep it as simple as possible. 52 | 53 | __UPDATE:__ you can now set almost all config variables (non-secrets) in the [admin panel](#rails_admin). The app will always use the first existing record of the Global Config model. When the app starts or the record is updated it will set all config variables to ones present in the database instead of the global_config.yml 54 | 55 | ### General App Config 56 | 57 | We need to set the app_namm & app_domain in `global_config.yml` 58 | 59 | ```ruby 60 | app_name: 'Your App Name' 61 | app_domain: 'yoursite.com' 62 | ``` 63 | 64 | #### Secret Token 65 | 66 | Run `rake secret` in the console and copy the key, paste it in our `.env` file: 67 | 68 | ```html 69 | SECRET_KEY_BASE=YOUR_LONG_KEY 70 | ``` 71 | 72 | #### Livereload 73 | 74 | We are using guard livereload for dev. In development the browser will reload the site automatically. Very helpful for expediating design. To use this run the following in another terminal window: 75 | 76 | ```html 77 | guard 78 | ``` 79 | 80 | ### Database Connections 81 | 82 | In `config/database.yml` we need to change the database names to what you want to use for your app. This app is setup using a database located on the same machine. 83 | 84 | We are again using environment variables to set the database password for production. In your `.env` file you will need to add: 85 | 86 | ```html 87 | DATABASE_PASSWORD=YOUR_PASSWORD 88 | ``` 89 | 90 | By default we are using [Postgresql](http://www.postgresql.org/) for development, test, & production evironments. Rails ships with sqlite by default for development, but I highly recommend using the same database in development, testing, & production to ensure you are actually working with & testing what you are putting in production. To run Postgresql on OSX I highly recommend [this app](http://postgresapp.com/). 91 | 92 | Once you have added your correct credentials, and have Postgres running, we can go ahead and create our databases locally: 93 | 94 | ```html 95 | rake db:create db:migrate 96 | ``` 97 | 98 | To get all the tests working remeber to run this before each testing sessions - it will ensure your test database is inline with the development database structure: 99 | 100 | ```html 101 | rake db:test:prepare 102 | ``` 103 | 104 | In some cases you may need to tell Rails what environment to use for database commands, for example: 105 | 106 | ```html 107 | RAILS_ENV=test rake db:test:prepare 108 | ``` 109 | 110 | ### Configure Omniauth 111 | 112 | Omniauth is a authentication library that has many great gems that allow you to quickly add different authentication options to your project. Omniauth is pre-installed and the database is setup to allow for users to signin through multiple social accounts. 113 | 114 | To get started; in `global_config.yml` we want to set a default email address that will send notifications to users (password reset, welcome message, etc.) 115 | 116 | ```ruby 117 | default_email_address: 'general_email@email.com' 118 | ``` 119 | 120 | #### Twitter Login 121 | 122 | If you want to use Twitter auth in your app uncomment this line from `config/initializers/devise.rb` 123 | 124 | ```ruby 125 | # config.omniauth :twitter, ENV["TWITTER_APP_ID"], ENV["TWITTER_APP_SECRET"] 126 | ``` 127 | 128 | Next, get/create keys for your Twitter app [here](https://apps.twitter.com/). 129 | 130 | We need to add the Id to our `global_config.yml` 131 | 132 | ```ruby 133 | twitter_app_id: 'xxxxxxxx' 134 | ``` 135 | 136 | Finally, set the secret in our `.env` 137 | 138 | ```html 139 | TWITTER_APP_SECRET=YOUR_APP_SECRET 140 | ``` 141 | 142 | #### Facebook Login 143 | 144 | Same process as Twitter - get/create keys for your Facebook app [here](https://developers.facebook.com). 145 | 146 | 147 | #### LinkedIn Login 148 | 149 | Same process as Twitter - get/create keys for your LinkedIn app [here](https://developer.linkedin.com/). 150 | 151 | ### Configure Email Via SMTP 152 | 153 | We recommend you send your emails through [Mandrill](https://mandrillapp.com/) it's free for low usage and super easy to setup. 154 | 155 | Add your Mandrill account email to `global_config.yml` 156 | 157 | ```ruby 158 | mandrill_user: 'general_email@email.com' 159 | ``` 160 | 161 | Generate a new [API key on Mandrill's site](https://mandrillapp.com/settings/index/) and add it to our `.env` 162 | 163 | ```html 164 | MANDRILL_SECRET=YOUR_SECRET 165 | ``` 166 | 167 | ### Slack & Support Email 168 | 169 | We have included a Slack webhook gem to make setting up live notifications from you app super easy. Your whole team can know what is happening in app, get critical updates on the go, and keep their inbox empty. You will need to add an 'Incoming Webhook' integration for this to work. 170 | 171 | We will add the Slack Token for the inegration to our `.env` file: 172 | 173 | ```html 174 | SLACK_TOKEN=xxxxxxxx 175 | ``` 176 | Next, update the options avaliable for sending messages in `global_config.yml` 177 | 178 | ```ruby 179 | # Slack Team name 180 | slack_team: 'team-name' 181 | 182 | # Default Icon for Slack Sending Messages 183 | slack_icon_url: 'https://github.com/apple-touch-icon-144.png' 184 | 185 | # Default Slack User to send natifications as 186 | slack_user: 'Rails Bot' 187 | 188 | # Default contacts for technical request 189 | technical_slack_channel: '#technical' 190 | 191 | # Default contacts for feedback 192 | feedback_slack_channel: '#feedback' 193 | 194 | # Default for all other notifications 195 | default_slack_channel: '#general' 196 | ``` 197 | When sending notifications there are many more options & ways to make this more dynamic for your needs - sending users profile images as icons for example - refer to the [docs here.](https://github.com/rikas/slack-poster) 198 | 199 | If you don't want to use Slack we have included an option for that as well, simple swap the following to false: 200 | 201 | ```ruby 202 | use_slack: true 203 | ``` 204 | 205 | #### Email Support 206 | 207 | For email support we have 3 different default teams to send support emails to. Update where to send these in `global_config.yml` 208 | 209 | ```ruby 210 | # Default contacts for technical request 211 | technical_support_email: 'tech_team@email.com' 212 | 213 | # Default contacts for feedback 214 | feedback_support_email: 'support_team@email.com' 215 | 216 | # Default for all other emails & notifications 217 | default_email_address: 'general_email@email.com' 218 | ``` 219 | 220 | ## Using Rails Admin panel 221 | 222 | [Rails Admin](https://github.com/sferik/rails_admin) generates a basic admin panel that lets you CRUD any resource and is fairly easy to extend. 223 | 224 | We have added an admin boolean to the users table to indicate if that user has certain permissions. Devise does work for multiple user types if you want to make a seperate admin model, but for simplicity we have decided to use this user setting. 225 | 226 | The default admin panel can be found at `yourdomain.com/admin` The first user to visit this url is made an admin. After that you can with make another user an admin by using the admin panel to update the user record, or update the user from the rails console. 227 | 228 | __UPDATE:__ you can now set almost all config variables in the admin panel. The app will always use the first existing record of the Global Config model. When the app starts or the record is updated it will set all config variables to ones present in the database instead of the global_config.yml 229 | 230 | NOTE: Mandrill user for email SMTP will still need to be set in global_config.yml for intialization reasons. 231 | 232 | ## Running the Test Suite 233 | 234 | We are using [Rspec](https://github.com/rspec/rspec) for testing. To run the exisitng tests in command line type: 235 | 236 | ```html 237 | rspec 238 | ``` 239 | 240 | K.I.S.S. To learn more about writing tests in Rails using this setup I highly recommend [Everyday Rails, Testing with RSpec](https://leanpub.com/everydayrailsrspec?a=1i6GUwZeH5Hg_yvzO2SWPv). It goes over all the basics & gives you a practical approach to Test Driven Development. 241 | 242 | ## How do I deploy this? 243 | 244 | Skip this if you are hosting on [Heroku](https://www.heroku.com/). You will use the super simple [Heroku Toolbelt](https://toolbelt.heroku.com/). 245 | 246 | If you are looking for production level deployment on non-Heroku hosts, read on. 247 | 248 | We are using [Capistrano](https://github.com/capistrano/capistrano) for deployment. It will version, test, and deploy our latest code from a git repo to multiple environments with one line from the command line. 249 | 250 | In this repo we have included the cap files and deployment setup, however, in practice you should gitignore these files to ensure no server details are stored in git. 251 | 252 | To get started open `config/deploy.rb` and customize the following lines to match your app: 253 | 254 | ```ruby 255 | set :application, 'rails-4-boilerplate' 256 | set :repo_url, 'git@github.com:TristanToye/rails-4-boilerplate.git' 257 | set :deploy_to, '/var/www/rails-4-boilerplate' 258 | ``` 259 | 260 | The deloy_to is where your web server is pointing port 80 to. 261 | 262 | Next you will a folder config/deploy that contains two files, these are the config files for each environment you are looking to deploy to. You will need to replace the following with your own server details: 263 | 264 | ```ruby 265 | role :app, %w{deploy@example.com} 266 | role :web, %w{deploy@example.com} 267 | role :db, %w{deploy@example.com} 268 | ``` 269 | 270 | ```ruby 271 | server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value 272 | ``` 273 | 274 | To make deployment super simple, [setup a ssh key](https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys--2) for each environment. Uncomment these lines and specify where your local key is. 275 | 276 | ```ruby 277 | set :ssh_options, { 278 | keys: %w(/home/USERNAME/.ssh/id_rsa), 279 | forward_agent: false, 280 | auth_methods: %w(password) 281 | } 282 | ``` 283 | 284 | To deploy simply type the following in the command line: 285 | 286 | ```html 287 | cap production deploy 288 | ``` 289 | 290 | You may run into some memory problems with large git repos. Often a server restart can be a quick fix for freeing up a bit of memory: 291 | 292 | ```html 293 | sudo service nginx restart 294 | ``` 295 | 296 | ## How do I setup a server for this? 297 | 298 | If you are just testing & developing nothing beats the simplicity and freeness of [Heroku](https://www.heroku.com/). They have everything ready to go out of the box and their documentation & command line tools are awesome. 299 | 300 | If you are looking for production level servers, read on. 301 | 302 | When setting up new servers I highly recommend making a image or snapshot of the server once setup and working. This way you can rapidly deploy new servers from that image, swap your rails app, and be ready to go in minutes. 303 | 304 | If you are just getting started, or working on a small project I highly recommend using [DigitalOcean](https://www.digitalocean.com/?refcode=7b495d17cb37) for getting setup. They have a preconfigured server setup for Ruby on Rails using Nginx & Unicorn, and hosting starts at just $5/m - which is a great price for deploying a Rails app. 305 | 306 | For our setup we are using [Rackspace as part of their Startups Program](http://rackspacestartups.com/) & have the following setup: 307 | * [Ubuntu 14.04 Server](http://releases.ubuntu.com/14.04.1/) 308 | * [Nginx](http://nginx.org/) - Web server 309 | * [Phusion Passenger](https://www.phusionpassenger.com/documentation/Users%20guide%20Nginx.html) - Rails web app manager 310 | 311 | DigitalOcean has by far the best documentation for setting up the stack we use. [Check it out here](https://www.digitalocean.com/community/tutorials/how-to-install-rails-and-nginx-with-passenger-on-ubuntu) 312 | 313 | ## Other things coming soon: 314 | 315 | * How to get to the moon on Rails 316 | * More test coverage 317 | * UI Dashboard improvment 318 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TristanToye/rails-4-boilerplate/03db56b5e3a77987af0a35908282014e9fd2e068/app/assets/images/.keep -------------------------------------------------------------------------------- /app/assets/images/rails-4-boilerplate.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TristanToye/rails-4-boilerplate/03db56b5e3a77987af0a35908282014e9fd2e068/app/assets/images/rails-4-boilerplate.gif -------------------------------------------------------------------------------- /app/assets/images/ruby-on-rails.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TristanToye/rails-4-boilerplate/03db56b5e3a77987af0a35908282014e9fd2e068/app/assets/images/ruby-on-rails.jpg -------------------------------------------------------------------------------- /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 vendor/assets/javascripts of plugins, if any, 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/sstephenson/sprockets#sprockets-directives) for details 11 | // about supported directives. 12 | // 13 | //= require jquery 14 | //= require bootstrap-sprockets 15 | //= require jquery_ujs 16 | //= require turbolinks 17 | //= require_tree . 18 | -------------------------------------------------------------------------------- /app/assets/javascripts/shared.js.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/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, vendor/assets/stylesheets, 6 | * or vendor/assets/stylesheets of plugins, if any, 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 styles 10 | * defined in the other CSS/SCSS files in this directory. It is generally better to create a new 11 | * file per style scope. 12 | * 13 | */ 14 | 15 | /* BOOTSTRAP */ 16 | @import "bootstrap-sprockets"; 17 | @import "bootstrap"; 18 | 19 | /* FONTAWESOME */ 20 | @import "font-awesome-sprockets"; 21 | @import "font-awesome"; 22 | 23 | // LANDING PAGE 24 | @import "landing-page"; 25 | 26 | // DASHBOARD LAYOUT 27 | @import "dashboard"; -------------------------------------------------------------------------------- /app/assets/stylesheets/dashboard.scss: -------------------------------------------------------------------------------- 1 | // Keeping all css in one file for the dashboard if useful to make sure you can easily change the layout without a problem. 2 | 3 | .dashboard{ 4 | /* 5 | * Global add-ons 6 | */ 7 | 8 | .sub-header { 9 | padding-bottom: 10px; 10 | border-bottom: 1px solid #eee; 11 | } 12 | 13 | /* 14 | * Top navigation 15 | * Hide default border to remove 1px line. 16 | */ 17 | .navbar-fixed-top { 18 | border: 0; 19 | } 20 | 21 | .gravatar{ 22 | border-radius: 3px; 23 | margin-right: 10px; 24 | } 25 | 26 | /* 27 | * Sidebar 28 | */ 29 | 30 | /* Hide for mobile, show later */ 31 | .sidebar { 32 | display: none; 33 | } 34 | @media (min-width: 768px) { 35 | .sidebar { 36 | position: fixed; 37 | top: 51px; 38 | bottom: 0; 39 | left: 0; 40 | z-index: 1000; 41 | display: block; 42 | padding: 20px; 43 | overflow-x: hidden; 44 | overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */ 45 | background-color: #f5f5f5; 46 | border-right: 1px solid #eee; 47 | } 48 | } 49 | 50 | /* Sidebar navigation */ 51 | .nav-sidebar { 52 | margin-right: -21px; /* 20px padding + 1px border */ 53 | margin-bottom: 20px; 54 | margin-left: -20px; 55 | } 56 | .nav-sidebar > li > a { 57 | padding-right: 20px; 58 | padding-left: 20px; 59 | } 60 | .nav-sidebar > .active > a, 61 | .nav-sidebar > .active > a:hover, 62 | .nav-sidebar > .active > a:focus { 63 | color: #fff; 64 | background-color: #428bca; 65 | } 66 | 67 | 68 | /* 69 | * Main content 70 | */ 71 | 72 | .main { 73 | padding: 20px; 74 | } 75 | @media (min-width: 768px) { 76 | .main { 77 | padding-right: 40px; 78 | padding-left: 40px; 79 | } 80 | } 81 | .main .page-header { 82 | margin-top: 0; 83 | } 84 | 85 | 86 | /* 87 | * Placeholder dashboard ideas 88 | */ 89 | 90 | .placeholders { 91 | margin-bottom: 30px; 92 | text-align: center; 93 | } 94 | .placeholders h4 { 95 | margin-bottom: 0; 96 | } 97 | .placeholder { 98 | margin-bottom: 20px; 99 | } 100 | .placeholder img { 101 | display: inline-block; 102 | border-radius: 50%; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /app/assets/stylesheets/landing-page.scss: -------------------------------------------------------------------------------- 1 | // Keeping all the code for landing pages in one file is a good idea as this will likley change often as product grows. 2 | 3 | .landing-page{ 4 | height: 100%; 5 | 6 | color: #fff; 7 | text-align: center; 8 | text-shadow: 0 1px 3px rgba(0,0,0,.5); 9 | /* 10 | * Globals 11 | */ 12 | 13 | /* Links */ 14 | a, 15 | a:focus, 16 | a:hover { 17 | color: #fff; 18 | } 19 | 20 | /* Custom default button */ 21 | .btn-default, 22 | .btn-default:hover, 23 | .btn-default:focus { 24 | color: #333; 25 | text-shadow: none; /* Prevent inheritence from `body` */ 26 | background-color: #fff; 27 | border: 1px solid #fff; 28 | } 29 | 30 | /* Extra markup and styles for table-esque vertical and horizontal centering */ 31 | .site-wrapper { 32 | display: table; 33 | width: 100%; 34 | height: 100%; /* For at least Firefox */ 35 | min-height: 100%; 36 | -webkit-box-shadow: inset 0 0 100px rgba(0,0,0,.5); 37 | box-shadow: inset 0 0 100px rgba(0,0,0,.5); 38 | } 39 | .site-wrapper-inner { 40 | display: table-cell; 41 | vertical-align: top; 42 | } 43 | .cover-container { 44 | margin-right: auto; 45 | margin-left: auto; 46 | } 47 | 48 | /* Padding for spacing */ 49 | .inner { 50 | padding: 30px; 51 | } 52 | 53 | 54 | /* 55 | * Header 56 | */ 57 | .masthead-brand { 58 | margin-top: 10px; 59 | margin-bottom: 10px; 60 | } 61 | 62 | .masthead-nav > li { 63 | display: inline-block; 64 | } 65 | .masthead-nav > li + li { 66 | margin-left: 20px; 67 | } 68 | .masthead-nav > li > a { 69 | padding-right: 0; 70 | padding-left: 0; 71 | font-size: 16px; 72 | font-weight: bold; 73 | color: #fff; /* IE8 proofing */ 74 | color: rgba(255,255,255,.75); 75 | border-bottom: 2px solid transparent; 76 | } 77 | .masthead-nav > li > a:hover, 78 | .masthead-nav > li > a:focus { 79 | background-color: transparent; 80 | border-bottom-color: #a9a9a9; 81 | border-bottom-color: rgba(255,255,255,.25); 82 | } 83 | .masthead-nav > .active > a, 84 | .masthead-nav > .active > a:hover, 85 | .masthead-nav > .active > a:focus { 86 | color: #fff; 87 | border-bottom-color: #fff; 88 | } 89 | 90 | @media (min-width: 768px) { 91 | .masthead-brand { 92 | float: left; 93 | } 94 | .masthead-nav { 95 | float: right; 96 | } 97 | } 98 | 99 | 100 | /* 101 | * Cover 102 | */ 103 | 104 | .cover { 105 | padding: 0 20px; 106 | } 107 | .cover .btn-lg { 108 | padding: 10px 20px; 109 | font-weight: bold; 110 | } 111 | 112 | 113 | /* 114 | * Footer 115 | */ 116 | 117 | .mastfoot { 118 | color: #999; /* IE8 proofing */ 119 | color: rgba(255,255,255,.5); 120 | } 121 | 122 | 123 | /* 124 | * Affix and center 125 | */ 126 | 127 | @media (min-width: 768px) { 128 | /* Pull out the header and footer */ 129 | .masthead { 130 | position: fixed; 131 | top: 0; 132 | } 133 | .mastfoot { 134 | position: fixed; 135 | bottom: 0; 136 | } 137 | /* Start the vertical centering */ 138 | .site-wrapper-inner { 139 | vertical-align: middle; 140 | } 141 | /* Handle the widths */ 142 | .masthead, 143 | .mastfoot, 144 | .cover-container { 145 | width: 100%; /* Must be percentage or pixels for horizontal alignment */ 146 | } 147 | } 148 | 149 | @media (min-width: 992px) { 150 | .masthead, 151 | .mastfoot, 152 | .cover-container { 153 | width: 700px; 154 | } 155 | } 156 | } -------------------------------------------------------------------------------- /app/assets/stylesheets/shared.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the shared controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | -------------------------------------------------------------------------------- /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 | 6 | def ensure_signup_complete 7 | # Ensure we don't go into an infinite loop 8 | return if action_name == 'finish_signup' 9 | 10 | # Redirect to the 'finish_signup' page if the user 11 | # email hasn't been verified yet 12 | if current_user && !current_user.email_verified? 13 | redirect_to finish_signup_path(current_user) 14 | end 15 | end 16 | 17 | end 18 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TristanToye/rails-4-boilerplate/03db56b5e3a77987af0a35908282014e9fd2e068/app/controllers/concerns/.keep -------------------------------------------------------------------------------- /app/controllers/omniauth_callbacks_controller.rb: -------------------------------------------------------------------------------- 1 | class OmniauthCallbacksController < Devise::OmniauthCallbacksController 2 | def self.provides_callback_for(provider) 3 | class_eval %Q{ 4 | def #{provider} 5 | @user = User.find_for_oauth(env["omniauth.auth"], current_user) 6 | 7 | if @user.persisted? 8 | sign_in_and_redirect @user, event: :authentication 9 | set_flash_message(:notice, :success, kind: "#{provider}".capitalize) if is_navigational_format? 10 | else 11 | sesson["devise.#{provider}_data"] = env["omniauth.auth"] 12 | redirect_to new_user_registration_url 13 | end 14 | end 15 | } 16 | end 17 | 18 | [:twitter, :facebook, :linkedin].each do |provider| 19 | provides_callback_for provider 20 | end 21 | 22 | def after_sign_in_path_for(resource) 23 | if resource.email_verified? 24 | super resource 25 | else 26 | finish_signup_path(resource) 27 | end 28 | end 29 | end -------------------------------------------------------------------------------- /app/controllers/shared_controller.rb: -------------------------------------------------------------------------------- 1 | # This Controller is for all shared pages for the app - landing pages, about, terms of use, etc. 2 | 3 | class SharedController < ApplicationController 4 | layout :resolve_layout #Before rendering check which layout we should show 5 | 6 | def index 7 | redirect_to dashboard_users_path if current_user 8 | end 9 | 10 | # From Popup Support Form 11 | def send_support_request 12 | require 'slack-poster' 13 | 14 | message = params[:message] 15 | if current_user 16 | from = current_user.email 17 | is_user = 'is a current user' 18 | else 19 | from = params[:email] 20 | is_user = 'is not a current user' 21 | end 22 | 23 | # Check Type of Request 24 | case params[:message_type] 25 | when 'technical' 26 | to = APP_CONFIG["technical_support_email"] 27 | channel = APP_CONFIG["technical_slack_channel"] 28 | when 'feedback' 29 | to = APP_CONFIG["feedback_support_email"] 30 | channel = APP_CONFIG["feedback_slack_channel"] 31 | else 32 | to = APP_CONFIG["default_email_address"] 33 | channel = APP_CONFIG["default_slack_channel"] 34 | end 35 | 36 | # Email Appropriate Contact 37 | AdminMailer.send_support_request(to, from, message, is_user).deliver 38 | 39 | # Send Notification to Slack About Request 40 | if APP_CONFIG["use_slack"] 41 | 42 | options = { 43 | icon_url: APP_CONFIG["slack_icon_url"], 44 | username: APP_CONFIG["slack_user"], 45 | channel: channel 46 | } 47 | # Create new poster 48 | poster = Slack::Poster.new(APP_CONFIG["slack_team"], ENV["SLACK_TOKEN"], options) 49 | # Prepare message 50 | slack_message = "#{from} says: #{message} - #{from} #{is_user}" 51 | # Send slack notification 52 | poster.send_message(slack_message) 53 | end 54 | 55 | redirect_to :back, notice: "Message sent to our team!" 56 | end 57 | 58 | private 59 | 60 | # Determine layout based on action name 61 | def resolve_layout 62 | case action_name 63 | when 'index' 64 | 'blank' 65 | else 66 | 'application' 67 | end 68 | end 69 | 70 | end 71 | -------------------------------------------------------------------------------- /app/controllers/users_controller.rb: -------------------------------------------------------------------------------- 1 | class UsersController < ApplicationController 2 | layout :resolve_layout #Before rendering check which layout we should show 3 | before_action :set_user, only: [:index, :show, :edit, :update, :destroy] 4 | 5 | # After login go here 6 | def index 7 | 8 | end 9 | 10 | # GET /users/:id.:format 11 | def show 12 | # authorize! :read, @user 13 | end 14 | 15 | # GET /users/:id/edit 16 | def edit 17 | # authorize! :update, @user 18 | end 19 | 20 | # PATCH/PUT /users/:id.:format 21 | def update 22 | # authorize! :update, @user 23 | respond_to do |format| 24 | if @user.update(user_params) 25 | sign_in(@user == current_user ? @user : current_user, :bypass => true) 26 | format.html { redirect_to root_path, notice: 'Your profile was successfully updated.' } 27 | format.json { head :no_content } 28 | else 29 | format.html { render action: 'edit' } 30 | format.json { render json: @user.errors, status: :unprocessable_entity } 31 | end 32 | end 33 | end 34 | 35 | # GET/PATCH /users/:id/finish_signup 36 | def finish_signup 37 | # authorize! :update, @user 38 | if request.patch? && params[:user] #&& params[:user][:email] 39 | if @user.update(user_params) 40 | @user.skip_reconfirmation! 41 | sign_in(@user, :bypass => true) 42 | redirect_to @user, notice: 'Your profile was successfully updated.' 43 | else 44 | @show_errors = true 45 | end 46 | end 47 | end 48 | 49 | # DELETE /users/:id.:format 50 | def destroy 51 | # authorize! :delete, @user 52 | @user.destroy 53 | respond_to do |format| 54 | format.html { redirect_to root_url } 55 | format.json { head :no_content } 56 | end 57 | end 58 | 59 | private 60 | def set_user 61 | if current_user 62 | @user = current_user 63 | elsif params[:id] 64 | @user = User.find(params[:id]) 65 | end 66 | if @user 67 | # For Gravatar lookup 68 | @email_hash = Digest::MD5.hexdigest(@user.email.strip) 69 | else 70 | redirect_to new_user_session_path, alert: 'Please sign in to view dashboard' 71 | end 72 | end 73 | 74 | def user_params 75 | accessible = [:name, :email] # extend with your own params 76 | accessible << [ :password, :password_confirmation ] unless params[:user][:password].blank? 77 | params.require(:user).permit(accessible) 78 | end 79 | 80 | private 81 | 82 | # Determine layout based on action name 83 | def resolve_layout 84 | case action_name 85 | when 'index' 86 | 'dashboard' 87 | else 88 | 'application' 89 | end 90 | end 91 | end -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | 3 | end 4 | -------------------------------------------------------------------------------- /app/helpers/shared_helper.rb: -------------------------------------------------------------------------------- 1 | module SharedHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/mailers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TristanToye/rails-4-boilerplate/03db56b5e3a77987af0a35908282014e9fd2e068/app/mailers/.keep -------------------------------------------------------------------------------- /app/mailers/admin_mailer.rb: -------------------------------------------------------------------------------- 1 | class AdminMailer < ActionMailer::Base 2 | include Roadie::Rails::Automatic 3 | default from: "#{APP_CONFIG['app_name']} <#{APP_CONFIG['default_email_address']}>" 4 | 5 | def send_support_request(to, from, message, is_user) 6 | 7 | @to = to 8 | @from = from 9 | @message = message 10 | 11 | if is_user 12 | @is_user = "This is a registered user." 13 | else 14 | @is_user = "This is not one of our users." 15 | end 16 | 17 | mail(to: @to, from: @from, subject: "Support Request - #{APP_CONFIG['app_name']}") 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /app/models/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TristanToye/rails-4-boilerplate/03db56b5e3a77987af0a35908282014e9fd2e068/app/models/.keep -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TristanToye/rails-4-boilerplate/03db56b5e3a77987af0a35908282014e9fd2e068/app/models/concerns/.keep -------------------------------------------------------------------------------- /app/models/global_config.rb: -------------------------------------------------------------------------------- 1 | class GlobalConfig < ActiveRecord::Base 2 | after_update :update_global_config 3 | 4 | 5 | def update_global_config 6 | self.attributes.each do |attr_name, attr_value| 7 | APP_CONFIG[attr_name] = attr_value if attr_value != nil && attr_value != '' 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /app/models/identity.rb: -------------------------------------------------------------------------------- 1 | class Identity < ActiveRecord::Base 2 | belongs_to :user 3 | validates_presence_of :uid, :provider, :user_id 4 | validates_uniqueness_of :uid, :scope => :provider 5 | 6 | def self.find_for_oauth(auth) 7 | find_or_create_by(uid: auth.id, provider: auth.provider) 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /app/models/user.rb: -------------------------------------------------------------------------------- 1 | class User < ActiveRecord::Base 2 | 3 | # Define what an email should look like 4 | TEMP_EMAIL_PREFIX = 'change@me' 5 | TEMP_EMAIL_REGEX = /\Achange@me/ 6 | 7 | # Include default devise modules. Others available are: 8 | # :lockable, :timeoutable 9 | devise :database_authenticatable, :registerable, :confirmable, :omniauthable, 10 | :recoverable, :rememberable, :trackable, :validatable 11 | 12 | def self.find_for_oauth(auth, signed_in_resource = nil) 13 | 14 | # Get the identity and user if they exist 15 | identity = Identity.find_for_oauth(auth) 16 | 17 | # If a signed_in_resource is provided it always overrides the existing user 18 | # to prevent the identity being locked with accidentally created accounts. 19 | # Note that this may leave zombie accounts (with no associated identity) which 20 | # can be cleaned up at a later date. 21 | user = signed_in_resource ? signed_in_resource : identity.user 22 | 23 | # Create the user if needed 24 | if user.nil? 25 | 26 | # Get the existing user by email if the provider gives us a verified email. 27 | # If no verified email was provided we assign a temporary email and ask the 28 | # user to verify it on the next step via UsersController.finish_signup 29 | email_is_verified = auth.info.email && (auth.info.verified || auth.info.verified_email) 30 | email = auth.info.email if email_is_verified 31 | user = User.where(:email => email).first if email 32 | 33 | # Create the user if it's a new registration 34 | if user.nil? 35 | user = User.new( 36 | name: auth.extra.raw_info.name, 37 | #username: auth.info.nickname || auth.uid, 38 | email: email ? email : "#{TEMP_EMAIL_PREFIX}-#{auth.uid}-#{auth.provider}.com", 39 | password: Devise.friendly_token[0,20] 40 | ) 41 | user.skip_confirmation! 42 | user.save! 43 | end 44 | end 45 | 46 | # Associate the identity with the user if needed 47 | if identity.user != user 48 | identity.user = user 49 | identity.save! 50 | end 51 | user 52 | end 53 | 54 | def email_verified? 55 | self.email && self.email !~ TEMP_EMAIL_REGEX 56 | end 57 | 58 | def is_admin? 59 | self.admin 60 | end 61 | 62 | protected 63 | end 64 | -------------------------------------------------------------------------------- /app/views/admin_mailer/send_support_request.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | <%= @from %> has sent a support request! 8 | 43 | 44 | 45 |
46 | 94 |
47 | 48 | 59 | 68 | 82 | 93 |
49 | 50 | 58 |
57 |
51 | 52 | 56 |
53 | 54 | <%= @from %> has sent a support request! 55 |
60 | 61 | 67 |
66 |
62 | 65 |
63 | 64 |
69 | 70 | 81 |
80 |
71 | 72 | 79 |
73 |

<%= @from %> has sent a support request!

74 |

They need help with:

75 |

<%= @message %>

76 |

<%= @is_user %>

77 |

Please get back to them asap!

78 |
83 | 84 | 92 |
91 |
85 | 86 | 90 |
87 | 88 | Copyright © 2014, Rails 4 Boilerplate. 89 |
95 | 96 | 97 | -------------------------------------------------------------------------------- /app/views/layouts/_head.html.erb: -------------------------------------------------------------------------------- 1 | 2 | <%= APP_CONFIG["app_name"] %> 3 | <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> 4 | <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> 5 | <%= csrf_meta_tags %> 6 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | <%= render 'layouts/head' %> 4 | 5 | 6 |
7 |
8 |
9 | <% if notice %> 10 |

<%= notice %>

11 | <% end %> 12 | <% if alert %> 13 |

<%= alert %>

14 | <% end %> 15 | 16 | <%= yield %> 17 |
18 |
19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /app/views/layouts/blank.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | <%= render 'layouts/head' %> 4 | 5 | 6 |
7 |
8 |
9 | <% if notice %> 10 |

<%= notice %>

11 | <% end %> 12 | <% if alert %> 13 |

<%= alert %>

14 | <% end %> 15 |
16 |
17 |
18 | 19 | <%= yield %> 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/views/layouts/dashboard.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | <%= render 'layouts/head' %> 4 | 5 | 6 | 7 | 8 | <%= render 'layouts/partials/dashboard/nav' %> 9 | 10 | 11 |
12 |
13 | 14 | 15 | 18 | 19 | 20 |
21 | 22 |
23 |
24 |
25 | <% if notice %> 26 |

<%= notice %>

27 | <% end %> 28 | <% if alert %> 29 |

<%= alert %>

30 | <% end %> 31 |
32 |
33 |
34 | 35 | 36 | <%= yield %> 37 | 38 |
39 |
40 |
41 | 42 | 43 | <%= render 'shared/modals/send_support_request' %> 44 | 45 | 46 | -------------------------------------------------------------------------------- /app/views/layouts/partials/dashboard/_nav.html.erb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/views/layouts/partials/dashboard/_sidebar.html.erb: -------------------------------------------------------------------------------- 1 | 7 | 14 | -------------------------------------------------------------------------------- /app/views/shared/index.html.erb: -------------------------------------------------------------------------------- 1 | 8 | 9 |
10 |
11 | 12 |
13 | 14 |
15 | 16 |
17 |
18 |

<%= APP_CONFIG["app_name"] %>

19 | 26 |
27 |
28 | 29 |
30 |

Rails 4 Boilerplate demo.

31 |

The homepage for this demo can be found here: https://github.com/TristanToye/rails-4-boilerplate

32 |

33 | <% if !current_user %> 34 | <%= link_to "Sign Up", new_user_registration_path, class: "btn btn-primary" %> <%= link_to "Sign In", new_user_session_path, class: "btn btn-default" %> 35 | <% else %> 36 |

Welcome <%= current_user.email %>

37 |

<%= link_to "Update Profile", edit_user_path(id: current_user.id), class: "btn btn-default"%> 38 | <%= link_to "Edit Account", edit_user_registration_path, class: "btn btn-default"%> 39 | <%= link_to 'Admin Panel', rails_admin_path, class: "btn btn-default" if current_user.is_admin? %> 40 | <%= link_to 'Logout', destroy_user_session_path, :method => :delete , class: "btn btn-danger" %> 41 |

42 | <% end %> 43 |

44 |
45 | 46 |
47 |
48 |

Support

49 |
50 |
51 | 52 |
53 | 54 |
55 | 56 |
57 |
-------------------------------------------------------------------------------- /app/views/shared/modals/_send_support_request.html.erb: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/views/users/confirmations/new.html.erb: -------------------------------------------------------------------------------- 1 |

Resend confirmation instructions

2 | 3 | <%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %> 4 | <%= devise_error_messages! %> 5 | 6 |
7 | <%= f.label :email %>
8 | <%= f.email_field :email, autofocus: true %> 9 |
10 | 11 |
12 | <%= f.submit "Resend confirmation instructions" %> 13 |
14 | <% end %> 15 | 16 | <%= render "users/shared/links" %> 17 | -------------------------------------------------------------------------------- /app/views/users/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Edit Profile Info

2 | 3 | <%= form_for(@user, url: user_path(id: @user.id), html: { method: :put }) do |f| %> 4 | 5 |
6 | <%= f.label :name %>
7 | <%= f.text_field :name %> 8 |
9 | 10 |
11 | <%= f.submit "Update" %> 12 |
13 | <% end %> 14 | 15 | <%= link_to "Back", :back %> -------------------------------------------------------------------------------- /app/views/users/finish_signup.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

Add Email

3 | <%= form_for(current_user, :as => 'user', :url => finish_signup_path(current_user), :html => { role: 'form'}) do |f| %> 4 | <% if @show_errors && current_user.errors.any? %> 5 |
6 | <% current_user.errors.full_messages.each do |msg| %> 7 | <%= msg %>
8 | <% end %> 9 |
10 | <% end %> 11 |
12 | <%= f.label :email %> 13 |
14 | <%= f.text_field :email, :autofocus => true, :value => '', class: 'form-control input-lg', placeholder: 'Example: email@me.com' %> 15 |

Please confirm your email address. No spam.

16 |
17 |
18 |
19 | <%= f.submit 'Continue', :class => 'btn btn-primary' %> 20 |
21 | <% end %> 22 |
-------------------------------------------------------------------------------- /app/views/users/index.html.erb: -------------------------------------------------------------------------------- 1 |

Dashboard

2 | 3 |
4 |
5 | Generic placeholder thumbnail 6 |

Label

7 | Something else 8 |
9 |
10 | Generic placeholder thumbnail 11 |

Label

12 | Something else 13 |
14 |
15 | Generic placeholder thumbnail 16 |

Label

17 | Something else 18 |
19 |
20 | Generic placeholder thumbnail 21 |

Label

22 | Something else 23 |
24 |
25 | 26 |

Section title

27 |
28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 |
#HeaderHeaderHeaderHeader
1,001Loremipsumdolorsit
1,002ametconsecteturadipiscingelit
1,003IntegernecodioPraesent
1,003liberoSedcursusante
1,004dapibusdiamSednisi
1,005Nullaquissemat
1,006nibhelementumimperdietDuis
1,007sagittisipsumPraesentmauris
1,008Fuscenectellussed
1,009auguesemperportaMauris
1,010massaVestibulumlaciniaarcu
1,011egetnullaClassaptent
1,012tacitisociosquadlitora
1,013torquentperconubianostra
1,014perinceptoshimenaeosCurabitur
1,015sodalesligulainlibero
153 |
-------------------------------------------------------------------------------- /app/views/users/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 | -------------------------------------------------------------------------------- /app/views/users/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/users/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/users/passwords/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Change your password

2 | 3 | <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %> 4 | <%= devise_error_messages! %> 5 | <%= f.hidden_field :reset_password_token %> 6 | 7 |
8 | <%= f.label :password, "New password" %>
9 | <%= f.password_field :password, autofocus: true, autocomplete: "off" %> 10 |
11 | 12 |
13 | <%= f.label :password_confirmation, "Confirm new password" %>
14 | <%= f.password_field :password_confirmation, autocomplete: "off" %> 15 |
16 | 17 |
18 | <%= f.submit "Change my password" %> 19 |
20 | <% end %> 21 | 22 | <%= render "users/shared/links" %> 23 | -------------------------------------------------------------------------------- /app/views/users/passwords/new.html.erb: -------------------------------------------------------------------------------- 1 |

Forgot your password?

2 | 3 | <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %> 4 | <%= devise_error_messages! %> 5 | 6 |
7 | <%= f.label :email %>
8 | <%= f.email_field :email, autofocus: true %> 9 |
10 | 11 |
12 | <%= f.submit "Send me reset password instructions" %> 13 |
14 | <% end %> 15 | 16 | <%= render "users/shared/links" %> 17 | -------------------------------------------------------------------------------- /app/views/users/registrations/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Edit <%= resource_name.to_s.humanize %>

2 | 3 | <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> 4 | <%= devise_error_messages! %> 5 | 6 |
7 | <%= f.label :email %>
8 | <%= f.email_field :email, autofocus: true %> 9 |
10 | 11 | <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> 12 |
Currently waiting confirmation for: <%= resource.unconfirmed_email %>
13 | <% end %> 14 | 15 |
16 | <%= f.label :password %> (leave blank if you don't want to change it)
17 | <%= f.password_field :password, autocomplete: "off" %> 18 |
19 | 20 |
21 | <%= f.label :password_confirmation %>
22 | <%= f.password_field :password_confirmation, autocomplete: "off" %> 23 |
24 | 25 |
26 | <%= f.label :current_password %> (we need your current password to confirm your changes)
27 | <%= f.password_field :current_password, autocomplete: "off" %> 28 |
29 | 30 |
31 | <%= f.submit "Update" %> 32 |
33 | <% end %> 34 | 35 |

Cancel my account

36 | 37 |

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

38 | 39 | <%= link_to "Back", :back %> 40 | -------------------------------------------------------------------------------- /app/views/users/registrations/new.html.erb: -------------------------------------------------------------------------------- 1 |

Sign up NOW

2 | 3 | <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> 4 | <%= devise_error_messages! %> 5 | 6 |
7 | <%= f.label :email %>
8 | <%= f.email_field :email, autofocus: true %> 9 |
10 | 11 |
12 | <%= f.label :password %> 13 | <% if @validatable %> 14 | (<%= @minimum_password_length %> characters minimum) 15 | <% end %>
16 | <%= f.password_field :password, autocomplete: "off" %> 17 |
18 | 19 |
20 | <%= f.label :password_confirmation %>
21 | <%= f.password_field :password_confirmation, autocomplete: "off" %> 22 |
23 | 24 |
25 | <%= f.submit "Sign up" %> 26 |
27 | <% end %> 28 | 29 | <%= render "users/shared/links" %> 30 | -------------------------------------------------------------------------------- /app/views/users/sessions/new.html.erb: -------------------------------------------------------------------------------- 1 |

Log in

2 | 3 | <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> 4 |
5 | <%= f.label :email %>
6 | <%= f.email_field :email, autofocus: true %> 7 |
8 | 9 |
10 | <%= f.label :password %>
11 | <%= f.password_field :password, autocomplete: "off" %> 12 |
13 | 14 | <% if devise_mapping.rememberable? -%> 15 |
16 | <%= f.check_box :remember_me %> 17 | <%= f.label :remember_me %> 18 |
19 | <% end -%> 20 | 21 |
22 | <%= f.submit "Log in" %> 23 |
24 | <% end %> 25 | 26 | <%= render "users/shared/links" %> 27 | -------------------------------------------------------------------------------- /app/views/users/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 #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %>
24 | <% end -%> 25 | <% end -%> 26 | -------------------------------------------------------------------------------- /app/views/users/unlocks/new.html.erb: -------------------------------------------------------------------------------- 1 |

Resend unlock instructions

2 | 3 | <%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %> 4 | <%= devise_error_messages! %> 5 | 6 |
7 | <%= f.label :email %>
8 | <%= f.email_field :email, autofocus: true %> 9 |
10 | 11 |
12 | <%= f.submit "Resend unlock instructions" %> 13 |
14 | <% end %> 15 | 16 | <%= render "users/shared/links" %> 17 | -------------------------------------------------------------------------------- /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/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 | ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR) 12 | ENV["GEM_HOME"] = "" 13 | Gem.paths = ENV 14 | 15 | gem "spring", match[1] 16 | require "spring/binstub" 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /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 | require 'yaml' 5 | 6 | APP_CONFIG = YAML.load_file("config/global_config.yml") 7 | 8 | # Require the gems listed in Gemfile, including any gems 9 | # you've limited to :test, :development, or :production. 10 | Bundler.require(*Rails.groups) 11 | 12 | module Rails4Boilerplate 13 | class Application < Rails::Application 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 | 18 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 19 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 20 | # config.time_zone = 'Central Time (US & Canada)' 21 | 22 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 23 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 24 | # config.i18n.default_locale = :de 25 | 26 | # Tell Rails to use rspec and factory girl 27 | config.generators do |g| 28 | g.test_framework :rspec, 29 | fixtures: true, 30 | view_specs: false, 31 | helper_specs: false, 32 | routing_specs: false, 33 | controller_specs: true, 34 | request_specs: false 35 | g.fixture_replacement :factory_girl, dir: "spec/factories" 36 | end 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | # Set up gems listed in the Gemfile. 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | 4 | require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) 5 | -------------------------------------------------------------------------------- /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: rails-4-boilerplate_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: rails-4-boilerplate 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: rails-4-boilerplate_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: rails-4-boilerplate_production 84 | username: rails-4-boilerplate 85 | password: <%= ENV['DATABASE_PASSWORD'] %> 86 | -------------------------------------------------------------------------------- /config/deploy.rb: -------------------------------------------------------------------------------- 1 | # config valid only for current version of Capistrano 2 | lock '3.3.5' 3 | 4 | set :application, 'rails-4-boilerplate' 5 | set :repo_url, 'git@github.com:TristanToye/rails-4-boilerplate.git' 6 | 7 | # Default branch is :master 8 | # ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call 9 | 10 | # Default deploy_to directory is /var/www/my_app_name 11 | set :deploy_to, '/var/www/rails-4-boilerplate' 12 | 13 | # Default value for :scm is :git 14 | set :scm, :git 15 | set :branch, "master" 16 | 17 | # Default value for :format is :pretty 18 | # set :format, :pretty 19 | 20 | # Default value for :log_level is :debug 21 | # set :log_level, :debug 22 | 23 | # Default value for :pty is false 24 | # set :pty, true 25 | 26 | # Default value for :linked_files is [] 27 | # set :linked_files, fetch(:linked_files, []).push('config/database.yml') 28 | 29 | # Default value for linked_dirs is [] 30 | # set :linked_dirs, fetch(:linked_dirs, []).push('bin', 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system') 31 | 32 | # Default value for default_env is {} 33 | # set :default_env, { path: "/opt/ruby/bin:$PATH" } 34 | 35 | # Default value for keep_releases is 5 36 | # set :keep_releases, 5 37 | 38 | # User 39 | # set :user, "USERNAME" 40 | 41 | # Rails env 42 | set :rails_env, "production" 43 | 44 | set :deploy_via, :copy 45 | 46 | # set :ssh_options, { :forward_agent => true} 47 | 48 | namespace :deploy do 49 | 50 | desc 'Restart application' 51 | task :restart do 52 | on roles(:app), in: :sequence, wait: 5 do 53 | # Your restart mechanism here, for example: 54 | execute :touch, release_path.join('tmp/restart.txt') 55 | end 56 | end 57 | 58 | after :publishing, :restart 59 | 60 | after :restart, :clear_cache do 61 | on roles(:web), in: :groups, limit: 3, wait: 10 do 62 | # Here we can do anything such as: 63 | # within release_path do 64 | # execute :rake, 'cache:clear' 65 | # end 66 | end 67 | end 68 | 69 | end 70 | -------------------------------------------------------------------------------- /config/deploy/production.rb: -------------------------------------------------------------------------------- 1 | # Simple Role Syntax 2 | # ================== 3 | # Supports bulk-adding hosts to roles, the primary server in each group 4 | # is considered to be the first unless any hosts have the primary 5 | # property set. Don't declare `role :all`, it's a meta role. 6 | 7 | role :app, %w{deploy@example.com} 8 | role :web, %w{deploy@example.com} 9 | role :db, %w{deploy@example.com} 10 | 11 | 12 | # Extended Server Syntax 13 | # ====================== 14 | # This can be used to drop a more detailed server definition into the 15 | # server list. The second argument is a, or duck-types, Hash and is 16 | # used to set extended properties on the server. 17 | 18 | server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value 19 | 20 | 21 | # Custom SSH Options 22 | # ================== 23 | # You may pass any option but keep in mind that net/ssh understands a 24 | # limited set of options, consult[net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start). 25 | # 26 | # Global options 27 | # -------------- 28 | # set :ssh_options, { 29 | # keys: %w(/home/USERNAME/.ssh/id_rsa), 30 | # forward_agent: false, 31 | # auth_methods: %w(password) 32 | # } 33 | # 34 | # And/or per server (overrides global) 35 | # ------------------------------------ 36 | # server 'example.com', 37 | # user: 'user_name', 38 | # roles: %w{web app}, 39 | # ssh_options: { 40 | # user: 'user_name', # overrides user setting above 41 | # keys: %w(/home/user_name/.ssh/id_rsa), 42 | # forward_agent: false, 43 | # auth_methods: %w(publickey password) 44 | # # password: 'please use keys' 45 | # } 46 | -------------------------------------------------------------------------------- /config/deploy/staging.rb: -------------------------------------------------------------------------------- 1 | # Simple Role Syntax 2 | # ================== 3 | # Supports bulk-adding hosts to roles, the primary server in each group 4 | # is considered to be the first unless any hosts have the primary 5 | # property set. Don't declare `role :all`, it's a meta role. 6 | 7 | role :app, %w{deploy@example.com} 8 | role :web, %w{deploy@example.com} 9 | role :db, %w{deploy@example.com} 10 | 11 | 12 | # Extended Server Syntax 13 | # ====================== 14 | # This can be used to drop a more detailed server definition into the 15 | # server list. The second argument is a, or duck-types, Hash and is 16 | # used to set extended properties on the server. 17 | 18 | server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value 19 | 20 | 21 | # Custom SSH Options 22 | # ================== 23 | # You may pass any option but keep in mind that net/ssh understands a 24 | # limited set of options, consult[net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start). 25 | # 26 | # Global options 27 | # -------------- 28 | # set :ssh_options, { 29 | # keys: %w(/home/USERNAME/.ssh/id_rsa), 30 | # forward_agent: false, 31 | # auth_methods: %w(password) 32 | # } 33 | # 34 | # And/or per server (overrides global) 35 | # ------------------------------------ 36 | # server 'example.com', 37 | # user: 'user_name', 38 | # roles: %w{web app}, 39 | # ssh_options: { 40 | # user: 'user_name', # overrides user setting above 41 | # keys: %w(/home/user_name/.ssh/id_rsa), 42 | # forward_agent: false, 43 | # auth_methods: %w(publickey password) 44 | # # password: 'please use keys' 45 | # } 46 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # require '#{ Rails.root }/config/initializers/global_config.rb' 5 | 6 | # Initialize the Rails application. 7 | Rails.application.initialize! 8 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # Add Rack::LiveReload to the bottom of the middleware stack with the default options. 5 | config.middleware.insert_after ActionDispatch::Static, Rack::LiveReload 6 | 7 | # In the development environment your application's code is reloaded on 8 | # every request. This slows down response time but is perfect for development 9 | # since you don't have to restart the web server when you make code changes. 10 | config.cache_classes = false 11 | 12 | # Do not eager load code on boot. 13 | config.eager_load = false 14 | 15 | # Show full error reports and disable caching. 16 | config.consider_all_requests_local = true 17 | config.action_controller.perform_caching = false 18 | 19 | # Don't care if the mailer can't send. 20 | config.action_mailer.raise_delivery_errors = false 21 | 22 | # Print deprecation notices to the Rails logger. 23 | config.active_support.deprecation = :log 24 | 25 | # Raise an error on page load if there are pending migrations. 26 | config.active_record.migration_error = :page_load 27 | 28 | # Debug mode disables concatenation and preprocessing of assets. 29 | # This option may cause significant delays in view rendering with a large 30 | # number of complex assets. 31 | config.assets.debug = true 32 | 33 | # Adds additional error checking when serving assets at runtime. 34 | # Checks for improperly declared sprockets dependencies. 35 | # Raises helpful error messages. 36 | config.assets.raise_runtime_errors = true 37 | 38 | # Raises error for missing translations 39 | # config.action_view.raise_on_missing_translations = true 40 | 41 | # Email 42 | config.action_mailer.delivery_method = :smtp 43 | config.action_mailer.perform_deliveries = true 44 | config.action_mailer.raise_delivery_errors = true 45 | # config.action_mailer.default_url_options = { :host => config.app_domain } 46 | config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } 47 | config.action_mailer.smtp_settings = { 48 | address: 'smtp.mandrillapp.com', 49 | port: '587', 50 | enable_starttls_auto: true, 51 | user_name: APP_CONFIG["mandrill_user"], 52 | password: ENV['MANDRILL_SECRET'], 53 | authentication: 'login', 54 | domain: 'localhost' 55 | } 56 | end 57 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | 3 | # ======================= 4 | # GENERAL 5 | # ======================= 6 | 7 | # Settings specified here will take precedence over those in config/application.rb. 8 | 9 | # Code is not reloaded between requests. 10 | config.cache_classes = true 11 | 12 | # Eager load code on boot. This eager loads most of Rails and 13 | # your application in memory, allowing both threaded web servers 14 | # and those relying on copy on write to perform better. 15 | # Rake tasks automatically ignore this option for performance. 16 | config.eager_load = true 17 | 18 | # Full error reports are disabled and caching is turned on. 19 | config.consider_all_requests_local = false 20 | config.action_controller.perform_caching = true 21 | 22 | # Enable Rack::Cache to put a simple HTTP cache in front of your application 23 | # Add `rack-cache` to your Gemfile before enabling this. 24 | # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. 25 | # config.action_dispatch.rack_cache = true 26 | 27 | # Disable Rails's static asset server (Apache or nginx will already do this). 28 | config.serve_static_files = true 29 | 30 | # Compress JavaScripts and CSS. 31 | config.assets.js_compressor = :uglifier 32 | config.assets.css_compressor = :sass 33 | 34 | # Do not fallback to assets pipeline if a precompiled asset is missed. 35 | config.assets.compile = false 36 | 37 | # Generate digests for assets URLs. 38 | config.assets.digest = true 39 | 40 | # `config.assets.precompile` has moved to config/initializers/assets.rb 41 | 42 | # Specifies the header that your server uses for sending files. 43 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache 44 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx 45 | 46 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 47 | # config.force_ssl = true 48 | 49 | # Set to :debug to see everything in the log. 50 | config.log_level = :warn 51 | 52 | # Prepend all log lines with the following tags. 53 | # config.log_tags = [ :subdomain, :uuid ] 54 | 55 | # Use a different logger for distributed setups. 56 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) 57 | 58 | # Use a different cache store in production. 59 | # config.cache_store = :mem_cache_store 60 | 61 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 62 | # config.action_controller.asset_host = "http://assets.example.com" 63 | 64 | # Precompile additional assets. 65 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. 66 | # config.assets.precompile += %w( search.js ) 67 | 68 | # Ignore bad email addresses and do not raise email delivery errors. 69 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 70 | # config.action_mailer.raise_delivery_errors = false 71 | 72 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 73 | # the I18n.default_locale when a translation cannot be found). 74 | config.i18n.fallbacks = true 75 | 76 | # Send deprecation notices to registered listeners. 77 | config.active_support.deprecation = :notify 78 | 79 | # Disable automatic flushing of the log to improve performance. 80 | # config.autoflush_log = false 81 | 82 | # Use default logging formatter so that PID and timestamp are not suppressed. 83 | config.log_formatter = ::Logger::Formatter.new 84 | 85 | # Do not dump schema after migrations. 86 | config.active_record.dump_schema_after_migration = false 87 | 88 | # ======================= 89 | # EMAIL 90 | # ======================= 91 | 92 | config.action_mailer.delivery_method = :smtp 93 | config.action_mailer.perform_deliveries = true 94 | config.action_mailer.default_url_options = { host: APP_CONFIG["app_domain"] } 95 | config.action_mailer.smtp_settings = { 96 | address: 'smtp.mandrillapp.com', 97 | port: '587', 98 | enable_starttls_auto: true, 99 | user_name: APP_CONFIG["mandrill_user"], 100 | password: ENV['MANDRILL_SECRET'], 101 | authentication: 'login', 102 | domain: APP_CONFIG["app_domain"] 103 | } 104 | end 105 | -------------------------------------------------------------------------------- /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 asset 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 | # Print deprecation notices to the stderr. 35 | config.active_support.deprecation = :stderr 36 | 37 | # Raises error for missing translations 38 | # config.action_view.raise_on_missing_translations = true 39 | 40 | config.action_mailer.default_url_options = { :host => "localhost", :post => 3000 } 41 | end 42 | -------------------------------------------------------------------------------- /config/global_config.yml: -------------------------------------------------------------------------------- 1 | # ::::::::::::::::: 2 | # App Settings 3 | # ::::::::::::::::: 4 | 5 | # Default domain name to be used 6 | app_name : 'Rails 4 Boilerplate' 7 | app_domain : 'rails-4-boilerplate.herokuapp.com' 8 | 9 | # ::::::::::::::::: 10 | # Social Login 11 | # ::::::::::::::::: 12 | 13 | facebook_app_id : 'xxxxxxxx' 14 | twitter_app_id : 'xxxxxxxx' 15 | linkedin_app_id : 'xxxxxxxx' 16 | 17 | # ::::::::::::::::: 18 | # Slack Settings 19 | # ::::::::::::::::: 20 | 21 | # Use Slack Notification for supprt and tracking 22 | use_slack : true 23 | # Slack Team name 24 | slack_team : 'team-name' 25 | # Default Icon for Slack Sending Messages 26 | slack_icon_url : 'https://github.com/apple-touch-icon-144.png' 27 | # Default Slack User to send natifications as 28 | slack_user : 'Rails Bot' 29 | 30 | # ::::::::::::::::: 31 | # Contact & Support 32 | # ::::::::::::::::: 33 | 34 | # Email for SMTP account with mandrill 35 | mandrill_user : 'rails4boilerplate@gmail.com' 36 | 37 | # Default contacts for technical request 38 | technical_support_email : 'rails4boilerplate@gmail.com' 39 | technical_slack_channel : '#technical' 40 | 41 | # Default contacts for feedback 42 | feedback_support_email : 'rails4boilerplate@gmail.com' 43 | feedback_slack_channel : '#feedback' 44 | 45 | # Default for all other emails & notifications 46 | default_email_address : 'rails4boilerplate@gmail.com' 47 | default_slack_channel : '#general' -------------------------------------------------------------------------------- /config/initializers/01_global_config.rb: -------------------------------------------------------------------------------- 1 | #Check we have generated a gonfig record 2 | if GlobalConfig.table_exists? 3 | if GlobalConfig.all.count != 0 4 | GlobalConfig.first.update_global_config 5 | else 6 | GlobalConfig.create 7 | end 8 | end -------------------------------------------------------------------------------- /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 | # Precompile additional assets. 7 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. 8 | # Rails.application.config.assets.precompile += %w( search.js ) 9 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /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 | # config.secret_key = 'e1a980169ca99c094c576db2f4d23d9499dacd203ff52ae45541e20d47c12979220c3b33dcb73e38740a24817536d2ab9c215301e9f58fddc8caccaf0dc08cb1' 8 | 9 | # ==> Mailer Configuration 10 | # Configure the e-mail address which will be shown in Devise::Mailer, 11 | # note that it will be overwritten if you use your own mailer class 12 | # with default "from" parameter. 13 | config.mailer_sender = APP_CONFIG["default_email_address"] 14 | 15 | # Configure the class responsible to send e-mails. 16 | # config.mailer = 'Devise::Mailer' 17 | 18 | # ==> ORM configuration 19 | # Load and configure the ORM. Supports :active_record (default) and 20 | # :mongoid (bson_ext recommended) by default. Other ORMs may be 21 | # available as additional gems. 22 | require 'devise/orm/active_record' 23 | 24 | # ==> Configuration for any authentication mechanism 25 | # Configure which keys are used when authenticating a user. The default is 26 | # just :email. You can configure it to use [:username, :subdomain], so for 27 | # authenticating a user, both parameters are required. Remember that those 28 | # parameters are used only when authenticating and not when retrieving from 29 | # session. If you need permissions, you should implement that in a before filter. 30 | # You can also supply a hash where the value is a boolean determining whether 31 | # or not authentication should be aborted when the value is not present. 32 | # config.authentication_keys = [ :email ] 33 | 34 | # Configure parameters from the request object used for authentication. Each entry 35 | # given should be a request method and it will automatically be passed to the 36 | # find_for_authentication method and considered in your model lookup. For instance, 37 | # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. 38 | # The same considerations mentioned for authentication_keys also apply to request_keys. 39 | # config.request_keys = [] 40 | 41 | # Configure which authentication keys should be case-insensitive. 42 | # These keys will be downcased upon creating or modifying a user and when used 43 | # to authenticate or find a user. Default is :email. 44 | config.case_insensitive_keys = [ :email ] 45 | 46 | # Configure which authentication keys should have whitespace stripped. 47 | # These keys will have whitespace before and after removed upon creating or 48 | # modifying a user and when used to authenticate or find a user. Default is :email. 49 | config.strip_whitespace_keys = [ :email ] 50 | 51 | # Tell if authentication through request.params is enabled. True by default. 52 | # It can be set to an array that will enable params authentication only for the 53 | # given strategies, for example, `config.params_authenticatable = [:database]` will 54 | # enable it only for database (email + password) authentication. 55 | # config.params_authenticatable = true 56 | 57 | # Tell if authentication through HTTP Auth is enabled. False by default. 58 | # It can be set to an array that will enable http authentication only for the 59 | # given strategies, for example, `config.http_authenticatable = [:database]` will 60 | # enable it only for database authentication. The supported strategies are: 61 | # :database = Support basic authentication with authentication key + password 62 | # config.http_authenticatable = false 63 | 64 | # If 401 status code should be returned for AJAX requests. True by default. 65 | # config.http_authenticatable_on_xhr = true 66 | 67 | # The realm used in Http Basic Authentication. 'Application' by default. 68 | # config.http_authentication_realm = 'Application' 69 | 70 | # It will change confirmation, password recovery and other workflows 71 | # to behave the same regardless if the e-mail provided was right or wrong. 72 | # Does not affect registerable. 73 | # config.paranoid = true 74 | 75 | # By default Devise will store the user in session. You can skip storage for 76 | # particular strategies by setting this option. 77 | # Notice that if you are skipping storage for all authentication paths, you 78 | # may want to disable generating routes to Devise's sessions controller by 79 | # passing skip: :sessions to `devise_for` in your config/routes.rb 80 | config.skip_session_storage = [:http_auth] 81 | 82 | # By default, Devise cleans up the CSRF token on authentication to 83 | # avoid CSRF token fixation attacks. This means that, when using AJAX 84 | # requests for sign in and sign up, you need to get a new CSRF token 85 | # from the server. You can disable this option at your own risk. 86 | # config.clean_up_csrf_token_on_authentication = true 87 | 88 | # ==> Configuration for :database_authenticatable 89 | # For bcrypt, this is the cost for hashing the password and defaults to 10. If 90 | # using other encryptors, it sets how many times you want the password re-encrypted. 91 | # 92 | # Limiting the stretches to just one in testing will increase the performance of 93 | # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use 94 | # a value less than 10 in other environments. Note that, for bcrypt (the default 95 | # encryptor), the cost increases exponentially with the number of stretches (e.g. 96 | # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation). 97 | config.stretches = Rails.env.test? ? 1 : 10 98 | 99 | # Setup a pepper to generate the encrypted password. 100 | # config.pepper = '422bf17b4406dedcb20f901441e060dff2662d1fa900e5e70f7a5cf75fe10900daadb526077fa0f3f456f599aa7de11e688507f75b870fae831e98c194f97300' 101 | 102 | # ==> Configuration for :confirmable 103 | # A period that the user is allowed to access the website even without 104 | # confirming their account. For instance, if set to 2.days, the user will be 105 | # able to access the website for two days without confirming their account, 106 | # access will be blocked just in the third day. Default is 0.days, meaning 107 | # the user cannot access the website without confirming their account. 108 | # config.allow_unconfirmed_access_for = 2.days 109 | 110 | # A period that the user is allowed to confirm their account before their 111 | # token becomes invalid. For example, if set to 3.days, the user can confirm 112 | # their account within 3 days after the mail was sent, but on the fourth day 113 | # their account can't be confirmed with the token any more. 114 | # Default is nil, meaning there is no restriction on how long a user can take 115 | # before confirming their account. 116 | # config.confirm_within = 3.days 117 | 118 | # If true, requires any email changes to be confirmed (exactly the same way as 119 | # initial account confirmation) to be applied. Requires additional unconfirmed_email 120 | # db field (see migrations). Until confirmed, new email is stored in 121 | # unconfirmed_email column, and copied to email column on successful confirmation. 122 | config.reconfirmable = true 123 | 124 | # Defines which key will be used when confirming an account 125 | # config.confirmation_keys = [ :email ] 126 | 127 | # ==> Configuration for :rememberable 128 | # The time the user will be remembered without asking for credentials again. 129 | # config.remember_for = 2.weeks 130 | 131 | # Invalidates all the remember me tokens when the user signs out. 132 | config.expire_all_remember_me_on_sign_out = true 133 | 134 | # If true, extends the user's remember period when remembered via cookie. 135 | # config.extend_remember_period = false 136 | 137 | # Options to be passed to the created cookie. For instance, you can set 138 | # secure: true in order to force SSL only cookies. 139 | # config.rememberable_options = {} 140 | 141 | # ==> Configuration for :validatable 142 | # Range for password length. 143 | config.password_length = 8..128 144 | 145 | # Email regex used to validate email formats. It simply asserts that 146 | # one (and only one) @ exists in the given string. This is mainly 147 | # to give user feedback and not to assert the e-mail validity. 148 | # config.email_regexp = /\A[^@]+@[^@]+\z/ 149 | 150 | # ==> Configuration for :timeoutable 151 | # The time you want to timeout the user session without activity. After this 152 | # time the user will be asked for credentials again. Default is 30 minutes. 153 | # config.timeout_in = 30.minutes 154 | 155 | # If true, expires auth token on session timeout. 156 | # config.expire_auth_token_on_timeout = false 157 | 158 | # ==> Configuration for :lockable 159 | # Defines which strategy will be used to lock an account. 160 | # :failed_attempts = Locks an account after a number of failed attempts to sign in. 161 | # :none = No lock strategy. You should handle locking by yourself. 162 | # config.lock_strategy = :failed_attempts 163 | 164 | # Defines which key will be used when locking and unlocking an account 165 | # config.unlock_keys = [ :email ] 166 | 167 | # Defines which strategy will be used to unlock an account. 168 | # :email = Sends an unlock link to the user email 169 | # :time = Re-enables login after a certain amount of time (see :unlock_in below) 170 | # :both = Enables both strategies 171 | # :none = No unlock strategy. You should handle unlocking by yourself. 172 | # config.unlock_strategy = :both 173 | 174 | # Number of authentication tries before locking an account if lock_strategy 175 | # is failed attempts. 176 | # config.maximum_attempts = 20 177 | 178 | # Time interval to unlock the account if :time is enabled as unlock_strategy. 179 | # config.unlock_in = 1.hour 180 | 181 | # Warn on the last attempt before the account is locked. 182 | # config.last_attempt_warning = true 183 | 184 | # ==> Configuration for :recoverable 185 | # 186 | # Defines which key will be used when recovering the password for an account 187 | config.reset_password_keys = [ :email ] 188 | 189 | # Time interval you can reset your password with a reset password key. 190 | # Don't put a too small interval or your users won't have the time to 191 | # change their passwords. 192 | config.reset_password_within = 6.hours 193 | 194 | # ==> Configuration for :encryptable 195 | # Allow you to use another encryption algorithm besides bcrypt (default). You can use 196 | # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1, 197 | # :authlogic_sha512 (then you should set stretches above to 20 for default behavior) 198 | # and :restful_authentication_sha1 (then you should set stretches to 10, and copy 199 | # REST_AUTH_SITE_KEY to pepper). 200 | # 201 | # Require the `devise-encryptable` gem when using anything other than bcrypt 202 | # config.encryptor = :sha512 203 | 204 | # ==> Scopes configuration 205 | # Turn scoped views on. Before rendering "sessions/new", it will first check for 206 | # "users/sessions/new". It's turned off by default because it's slower if you 207 | # are using only default views. 208 | config.scoped_views = true 209 | 210 | # Configure the default scope given to Warden. By default it's the first 211 | # devise role declared in your routes (usually :user). 212 | # config.default_scope = :user 213 | 214 | # Set this configuration to false if you want /users/sign_out to sign out 215 | # only the current scope. By default, Devise signs out all scopes. 216 | # config.sign_out_all_scopes = true 217 | 218 | # ==> Navigation configuration 219 | # Lists the formats that should be treated as navigational. Formats like 220 | # :html, should redirect to the sign in page when the user does not have 221 | # access, but formats like :xml or :json, should return 401. 222 | # 223 | # If you have any extra navigational formats, like :iphone or :mobile, you 224 | # should add them to the navigational formats lists. 225 | # 226 | # The "*/*" below is required to match Internet Explorer requests. 227 | # config.navigational_formats = ['*/*', :html] 228 | 229 | # The default HTTP method used to sign out a resource. Default is :delete. 230 | config.sign_out_via = :delete 231 | 232 | # ==> OmniAuth 233 | # Add a new OmniAuth provider. Check the wiki for more information on setting 234 | # up on your models and hooks. 235 | # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo' 236 | 237 | # Use Facebook Auth 238 | # config.omniauth :facebook, APP_CONFIG["facebook_app_id"], ENV["FACEBOOK_APP_SECRET"] 239 | 240 | # Use Twitter Auth 241 | # config.omniauth :twitter, APP_CONFIG["twitter_app_id"], ENV["TWITTER_APP_SECRET"] 242 | 243 | # Use Linkedin Auth 244 | # config.omniauth :linkedin, APP_CONFIG["LINKEDIN_APP_ID"], ENV["LINKEDIN_APP_SECRET"] 245 | 246 | # ==> Warden configuration 247 | # If you want to use other strategies, that are not supported by Devise, or 248 | # change the failure app, you can configure them inside the config.warden block. 249 | # 250 | # config.warden do |manager| 251 | # manager.intercept_401 = false 252 | # manager.default_strategies(scope: :user).unshift :some_external_strategy 253 | # end 254 | 255 | # ==> Mountable engine configurations 256 | # When using Devise inside an engine, let's call it `MyEngine`, and this engine 257 | # is mountable, there are some extra configurations to be taken into account. 258 | # The following options are available, assuming the engine is mounted as: 259 | # 260 | # mount MyEngine, at: '/my_engine' 261 | # 262 | # The router that invoked `devise_for`, in the example above, would be: 263 | # config.router_name = :my_engine 264 | # 265 | # When using omniauth, Devise cannot automatically set Omniauth path, 266 | # so you need to do it manually. For the users scope, it would be: 267 | # config.omniauth_path_prefix = '/my_engine/users/auth' 268 | end 269 | -------------------------------------------------------------------------------- /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/rails_admin.rb: -------------------------------------------------------------------------------- 1 | RailsAdmin.config do |config| 2 | 3 | ### Popular gems integration 4 | 5 | ## == Devise == 6 | config.authenticate_with do 7 | warden.authenticate! scope: :user 8 | end 9 | config.current_user_method(&:current_user) 10 | 11 | ## == Cancan == 12 | # config.authorize_with :cancan 13 | 14 | ## == Pundit == 15 | # config.authorize_with :pundit 16 | 17 | ## == PaperTrail == 18 | # config.audit_with :paper_trail, 'User', 'PaperTrail::Version' # PaperTrail >= 3.0.0 19 | 20 | ### More at https://github.com/sferik/rails_admin/wiki/Base-configuration 21 | 22 | config.actions do 23 | dashboard # mandatory 24 | index # mandatory 25 | new 26 | export 27 | bulk_delete 28 | show 29 | edit 30 | delete 31 | show_in_app 32 | 33 | ## With an audit adapter, you can add: 34 | # history_index 35 | # history_show 36 | end 37 | end 38 | 39 | require "rails_admin/application_controller" 40 | 41 | module RailsAdmin 42 | class ApplicationController < ::ApplicationController 43 | # Before loading the admin panel check if the user is an admin 44 | before_action :admin? 45 | private 46 | def admin? 47 | if !User.find_by(admin: true) 48 | current_user.update_attributes(admin: true) 49 | end 50 | if !current_user.admin 51 | redirect_to "/", alert: "You do not have permission to access that." 52 | end 53 | end 54 | end 55 | end 56 | -------------------------------------------------------------------------------- /config/initializers/secret_token.rb: -------------------------------------------------------------------------------- 1 | Rails4Boilerplate::Application.config.secret_key_base = ENV["SECRET_KEY_BASE"] -------------------------------------------------------------------------------- /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: '_rails-4-boilerplate_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/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 | omniauth_callbacks: 27 | failure: "Could not authenticate you from %{kind} because \"%{reason}\"." 28 | success: "Successfully authenticated from %{kind} account." 29 | passwords: 30 | 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." 31 | send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes." 32 | 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." 33 | updated: "Your password has been changed successfully. You are now signed in." 34 | updated_not_active: "Your password has been changed successfully." 35 | registrations: 36 | destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon." 37 | signed_up: "Welcome! You have signed up successfully." 38 | signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated." 39 | signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked." 40 | 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." 41 | 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." 42 | updated: "Your account has been updated successfully." 43 | sessions: 44 | signed_in: "Signed in successfully." 45 | signed_out: "Signed out successfully." 46 | already_signed_out: "Signed out successfully." 47 | unlocks: 48 | send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes." 49 | send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes." 50 | unlocked: "Your account has been unlocked successfully. Please sign in to continue." 51 | errors: 52 | messages: 53 | already_confirmed: "was already confirmed, please try signing in" 54 | confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one" 55 | expired: "has expired, please request a new one" 56 | not_found: "not found" 57 | not_locked: "was not locked" 58 | not_saved: 59 | one: "1 error prohibited this %{resource} from being saved:" 60 | other: "%{count} errors prohibited this %{resource} from being saved:" 61 | -------------------------------------------------------------------------------- /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 | Rails.application.routes.draw do 2 | 3 | mount RailsAdmin::Engine => '/admin', as: 'rails_admin' 4 | # ======================= 5 | # GENERAL 6 | # ======================= 7 | 8 | # You can have the root of your site routed with "root" 9 | root 'shared#index' 10 | 11 | # Send support form data 12 | match '/send_support_request' => 'shared#send_support_request', via: [:post] 13 | 14 | # ======================= 15 | # USERS 16 | # ======================= 17 | 18 | # User Authentication 19 | devise_for :users, :controllers => {omniauth_callbacks: 'omniauth_callbacks'} 20 | 21 | # After signup request extra user details 22 | match '/users/:id/finish_signup' => 'users#finish_signup', via: [:get, :patch], :as => :finish_signup 23 | 24 | resources :users, except: [:show, :new, :create] do 25 | collection do 26 | match "/dashboard", to: "users#index", via: [:get, :post] 27 | end 28 | end 29 | 30 | # The priority is based upon order of creation: first created -> highest priority. 31 | # See how all your routes lay out with "rake routes". 32 | 33 | # ======================= 34 | # UNUSED DEFAULTS 35 | # ======================= 36 | 37 | # Example of regular route: 38 | # get 'products/:id' => 'catalog#view' 39 | 40 | # Example of named route that can be invoked with purchase_url(id: product.id) 41 | # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase 42 | 43 | # Example resource route (maps HTTP verbs to controller actions automatically): 44 | # resources :products 45 | 46 | # Example resource route with options: 47 | # resources :products do 48 | # member do 49 | # get 'short' 50 | # post 'toggle' 51 | # end 52 | # 53 | # collection do 54 | # get 'sold' 55 | # end 56 | # end 57 | 58 | # Example resource route with sub-resources: 59 | # resources :products do 60 | # resources :comments, :sales 61 | # resource :seller 62 | # end 63 | 64 | # Example resource route with more complex sub-resources: 65 | # resources :products do 66 | # resources :comments 67 | # resources :sales do 68 | # get 'recent', on: :collection 69 | # end 70 | # end 71 | 72 | # Example resource route with concerns: 73 | # concern :toggleable do 74 | # post 'toggle' 75 | # end 76 | # resources :posts, concerns: :toggleable 77 | # resources :photos, concerns: :toggleable 78 | 79 | # Example resource route within a namespace: 80 | # namespace :admin do 81 | # # Directs /admin/products/* to Admin::ProductsController 82 | # # (app/controllers/admin/products_controller.rb) 83 | # resources :products 84 | # end 85 | end 86 | -------------------------------------------------------------------------------- /db/migrate/20150126180608_devise_create_users.rb: -------------------------------------------------------------------------------- 1 | class DeviseCreateUsers < ActiveRecord::Migration 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.inet :current_sign_in_ip 20 | t.inet :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 | # Custom Variables 34 | t.string :name 35 | t.boolean :admin, :default => false 36 | 37 | t.timestamps 38 | end 39 | 40 | add_index :users, :email, unique: true 41 | add_index :users, :reset_password_token, unique: true 42 | add_index :users, :confirmation_token, unique: true 43 | # add_index :users, :unlock_token, unique: true 44 | end 45 | 46 | end 47 | -------------------------------------------------------------------------------- /db/migrate/20150126180704_create_identities.rb: -------------------------------------------------------------------------------- 1 | class CreateIdentities < ActiveRecord::Migration 2 | def change 3 | create_table :identities do |t| 4 | t.references :user, index: true 5 | t.string :provider 6 | t.string :uid 7 | 8 | t.timestamps 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /db/migrate/20150129184051_create_global_configs.rb: -------------------------------------------------------------------------------- 1 | class CreateGlobalConfigs < ActiveRecord::Migration 2 | def change 3 | create_table :global_configs do |t| 4 | 5 | t.string :app_name 6 | t.string :app_domain 7 | 8 | t.string :facebook_app_id 9 | t.string :twitter_app_id 10 | t.string :linkedin_app_id 11 | 12 | t.boolean :use_slack, :default => false 13 | t.string :slack_team 14 | t.string :slack_icon_url 15 | t.string :slack_user 16 | 17 | t.string :technical_support_email 18 | t.string :technical_slack_channel 19 | t.string :feedback_support_email 20 | t.string :feedback_slack_channel 21 | t.string :default_email_address 22 | t.string :default_slack_channel 23 | 24 | t.timestamps 25 | end 26 | end 27 | end -------------------------------------------------------------------------------- /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: 20150129184051) do 15 | 16 | # These are extensions that must be enabled in order to support this database 17 | enable_extension "plpgsql" 18 | 19 | create_table "global_configs", force: :cascade do |t| 20 | t.string "app_name" 21 | t.string "app_domain" 22 | t.string "facebook_app_id" 23 | t.string "twitter_app_id" 24 | t.string "linkedin_app_id" 25 | t.boolean "use_slack", default: false 26 | t.string "slack_team" 27 | t.string "slack_icon_url" 28 | t.string "slack_user" 29 | t.string "technical_support_email" 30 | t.string "technical_slack_channel" 31 | t.string "feedback_support_email" 32 | t.string "feedback_slack_channel" 33 | t.string "default_email_address" 34 | t.string "default_slack_channel" 35 | t.datetime "created_at" 36 | t.datetime "updated_at" 37 | end 38 | 39 | create_table "identities", force: :cascade do |t| 40 | t.integer "user_id" 41 | t.string "provider" 42 | t.string "uid" 43 | t.datetime "created_at" 44 | t.datetime "updated_at" 45 | end 46 | 47 | add_index "identities", ["user_id"], name: "index_identities_on_user_id", using: :btree 48 | 49 | create_table "users", force: :cascade do |t| 50 | t.string "email", default: "", null: false 51 | t.string "encrypted_password", default: "", null: false 52 | t.string "reset_password_token" 53 | t.datetime "reset_password_sent_at" 54 | t.datetime "remember_created_at" 55 | t.integer "sign_in_count", default: 0, null: false 56 | t.datetime "current_sign_in_at" 57 | t.datetime "last_sign_in_at" 58 | t.inet "current_sign_in_ip" 59 | t.inet "last_sign_in_ip" 60 | t.string "confirmation_token" 61 | t.datetime "confirmed_at" 62 | t.datetime "confirmation_sent_at" 63 | t.string "unconfirmed_email" 64 | t.string "name" 65 | t.boolean "admin", default: false 66 | t.datetime "created_at" 67 | t.datetime "updated_at" 68 | end 69 | 70 | add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree 71 | add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree 72 | add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree 73 | 74 | end 75 | -------------------------------------------------------------------------------- /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/TristanToye/rails-4-boilerplate/03db56b5e3a77987af0a35908282014e9fd2e068/lib/assets/.keep -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TristanToye/rails-4-boilerplate/03db56b5e3a77987af0a35908282014e9fd2e068/lib/tasks/.keep -------------------------------------------------------------------------------- /log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TristanToye/rails-4-boilerplate/03db56b5e3a77987af0a35908282014e9fd2e068/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/TristanToye/rails-4-boilerplate/03db56b5e3a77987af0a35908282014e9fd2e068/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 | -------------------------------------------------------------------------------- /spec/controllers/shared_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe SharedController, :type => :controller do 4 | before :each do 5 | @admin_user = create(:admin_user) 6 | sign_in :user, @admin_user 7 | end 8 | 9 | describe "GET #index" do 10 | it "redirects if a user is signed in and confirmed" do 11 | sign_in :user, create(:user, confirmed_at: Date.today) 12 | get :index 13 | expect(response).to redirect_to(dashboard_users_path) 14 | end 15 | end 16 | 17 | describe "POST send_support_request" do 18 | 19 | end 20 | end -------------------------------------------------------------------------------- /spec/controllers/users_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe UsersController, :type => :controller do 4 | before :each do 5 | @user = create(:user, name: "Test", confirmed_at: Date.today) 6 | sign_in :user, @user 7 | request.env["HTTP_REFERER"] = "where_i_came_from" 8 | end 9 | 10 | it "is redirected to sign_in without a user" do 11 | sign_out :user 12 | expect(get :index).to redirect_to(new_user_session_path) 13 | end 14 | 15 | describe "GET #index" do 16 | it "redirects the user if not signed in" 17 | end 18 | 19 | describe "PATCH #update" do 20 | 21 | context "with valid attributes" do 22 | 23 | it "changes current_user's attributes" do 24 | patch :update, id: @user, user: build(:user, name: "test2").attributes 25 | @user.reload 26 | expect(@user.name).to eq("test2") 27 | end 28 | 29 | it "redirects to root" do 30 | patch :update, id: @user, user: build(:user).attributes 31 | expect(response).to redirect_to root_path 32 | end 33 | end 34 | 35 | end 36 | end -------------------------------------------------------------------------------- /spec/factories/global_configs.rb: -------------------------------------------------------------------------------- 1 | # Read about factories at https://github.com/thoughtbot/factory_girl 2 | 3 | FactoryGirl.define do 4 | factory :global_config do 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /spec/factories/identities.rb: -------------------------------------------------------------------------------- 1 | # Read about factories at https://github.com/thoughtbot/factory_girl 2 | 3 | FactoryGirl.define do 4 | factory :identity do 5 | association :user 6 | provider "facebook" 7 | uid {Faker::Lorem.characters([8,14])} 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /spec/factories/users.rb: -------------------------------------------------------------------------------- 1 | # Read about factories at https://github.com/thoughtbot/factory_girl 2 | 3 | FactoryGirl.define do 4 | factory :user do 5 | name {Faker::Name.name} 6 | email {Faker::Internet.email} 7 | admin false 8 | password {Faker::Internet.password(min_length = 8)} 9 | 10 | factory :invalid_user do 11 | email nil 12 | end 13 | 14 | factory :admin_user do 15 | admin true 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /spec/mailers/admin_mailer_spec.rb: -------------------------------------------------------------------------------- 1 | require "rails_helper" 2 | 3 | RSpec.describe AdminMailer, :type => :mailer do 4 | pending "add some examples to (or delete) #{__FILE__}" 5 | end -------------------------------------------------------------------------------- /spec/models/global_config_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe GlobalConfig, :type => :model do 4 | it "has a valid factory" do 5 | config = build(:global_config) 6 | expect(config).to be_valid 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /spec/models/identity_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe Identity, :type => :model do 4 | it "has a valid factory" do 5 | expect(build(:identity)).to be_valid 6 | end 7 | it "is associated with a user" do 8 | expect(build(:identity).user).to be_valid 9 | end 10 | it "is invalid without a user_id" do 11 | expect(build(:identity, user_id: nil)).to have(1).errors_on(:user_id) 12 | end 13 | it "is invalid without a provider" do 14 | expect(build(:identity, provider: nil)).to have(1).errors_on(:provider) 15 | end 16 | it "is invalid without a uid" do 17 | expect(build(:identity, uid: nil)).to have(1).errors_on(:uid) 18 | end 19 | end -------------------------------------------------------------------------------- /spec/models/user_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.describe User, :type => :model do 4 | it "has a valid factory" do 5 | expect(build(:user)).to be_valid 6 | end 7 | 8 | 9 | context "is invalid without" do 10 | it "an email" do 11 | user = build(:user, email: nil) 12 | expect(user).to have(1).errors_on(:email) 13 | end 14 | it "a password" do 15 | user = build(:user, password: nil) 16 | expect(user).to have(1).errors_on(:password) 17 | end 18 | end 19 | 20 | context "has dependencies" do 21 | before :each do 22 | @user = create(:user) 23 | end 24 | 25 | context "destroyed for it" do 26 | it "identities" do 27 | create(:identity, user: @user) 28 | @user.destroy 29 | expect(Identity.find_by(user_id: @user.id)).to eq nil 30 | end 31 | end 32 | end 33 | end -------------------------------------------------------------------------------- /spec/rails_helper.rb: -------------------------------------------------------------------------------- 1 | # This file is copied to spec/ when you run 'rails generate rspec:install' 2 | ENV["RAILS_ENV"] ||= 'test' 3 | require 'factory_girl_rails' 4 | require 'spec_helper' 5 | require File.expand_path("../../config/environment", __FILE__) 6 | require 'rspec/rails' 7 | require 'rspec/collection_matchers' 8 | require 'database_cleaner' 9 | # Add additional requires below this line. Rails is not loaded until this point! 10 | 11 | # Requires supporting ruby files with custom matchers and macros, etc, in 12 | # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are 13 | # run as spec files by default. This means that files in spec/support that end 14 | # in _spec.rb will both be required and run as specs, causing the specs to be 15 | # run twice. It is recommended that you do not name files matching this glob to 16 | # end with _spec.rb. You can configure this pattern with the --pattern 17 | # option on the command line or in ~/.rspec, .rspec or `.rspec-local`. 18 | Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } 19 | 20 | # The following line is provided for convenience purposes. It has the downside 21 | # of increasing the boot-up time by auto-requiring all files in the support 22 | # directory. Alternatively, in the individual `*_spec.rb` files, manually 23 | # require only the support files necessary. 24 | # 25 | # Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } 26 | 27 | # Checks for pending migrations before tests are run. 28 | # If you are not using ActiveRecord, you can remove this line. 29 | ActiveRecord::Migration.maintain_test_schema! 30 | 31 | RSpec.configure do |config| 32 | # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures 33 | config.fixture_path = "#{::Rails.root}/spec/fixtures" 34 | 35 | # If you're not using ActiveRecord, or you'd prefer not to run each of your 36 | # examples within a transaction, remove the following line or assign false 37 | # instead of true. 38 | config.use_transactional_fixtures = true 39 | 40 | # RSpec Rails can automatically mix in different behaviours to your tests 41 | # based on their file location, for example enabling you to call `get` and 42 | # `post` in specs under `spec/controllers`. 43 | # 44 | # You can disable this behaviour by removing the line below, and instead 45 | # explicitly tag your specs with their type, e.g.: 46 | # 47 | # RSpec.describe UsersController, :type => :controller do 48 | # # ... 49 | # end 50 | # 51 | # The different available types are documented in the features, such as in 52 | # https://relishapp.com/rspec/rspec-rails/docs 53 | config.infer_spec_type_from_file_location! 54 | 55 | # Allow for short methods of FactoryGirl to be user - build(:user) vs. FactoryGirl.build(:user) 56 | config.include FactoryGirl::Syntax::Methods 57 | 58 | # Clean database between test to avoid duplicating data 59 | config.before(:suite) do 60 | DatabaseCleaner[:active_record].strategy = :transaction 61 | DatabaseCleaner.clean_with(:truncation) 62 | end 63 | 64 | config.before(:each) do 65 | DatabaseCleaner.start 66 | end 67 | 68 | config.after(:each) do 69 | DatabaseCleaner.clean 70 | end 71 | 72 | # Allow devise methods in controller spec 73 | config.include Devise::TestHelpers, type: :controller 74 | end 75 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # This file was generated by the `rails generate rspec:install` command. Conventionally, all 2 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. 3 | # The generated `.rspec` file contains `--require spec_helper` which will cause this 4 | # file to always be loaded, without a need to explicitly require it in any files. 5 | # 6 | # Given that it is always loaded, you are encouraged to keep this file as 7 | # light-weight as possible. Requiring heavyweight dependencies from this file 8 | # will add to the boot time of your test suite on EVERY test run, even for an 9 | # individual file that may not need all of that loaded. Instead, consider making 10 | # a separate helper file that requires the additional dependencies and performs 11 | # the additional setup, and require it from the spec files that actually need it. 12 | # 13 | # The `.rspec` file also contains a few flags that are not defaults but that 14 | # users commonly want. 15 | # 16 | # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration 17 | RSpec.configure do |config| 18 | # rspec-expectations config goes here. You can use an alternate 19 | # assertion/expectation library such as wrong or the stdlib/minitest 20 | # assertions if you prefer. 21 | config.expect_with :rspec do |expectations| 22 | # This option will default to `true` in RSpec 4. It makes the `description` 23 | # and `failure_message` of custom matchers include text for helper methods 24 | # defined using `chain`, e.g.: 25 | # be_bigger_than(2).and_smaller_than(4).description 26 | # # => "be bigger than 2 and smaller than 4" 27 | # ...rather than: 28 | # # => "be bigger than 2" 29 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true 30 | end 31 | 32 | # rspec-mocks config goes here. You can use an alternate test double 33 | # library (such as bogus or mocha) by changing the `mock_with` option here. 34 | config.mock_with :rspec do |mocks| 35 | # Prevents you from mocking or stubbing a method that does not exist on 36 | # a real object. This is generally recommended, and will default to 37 | # `true` in RSpec 4. 38 | mocks.verify_partial_doubles = true 39 | end 40 | 41 | # The settings below are suggested to provide a good initial experience 42 | # with RSpec, but feel free to customize to your heart's content. 43 | =begin 44 | # These two settings work together to allow you to limit a spec run 45 | # to individual examples or groups you care about by tagging them with 46 | # `:focus` metadata. When nothing is tagged with `:focus`, all examples 47 | # get run. 48 | config.filter_run :focus 49 | config.run_all_when_everything_filtered = true 50 | 51 | # Limits the available syntax to the non-monkey patched syntax that is recommended. 52 | # For more details, see: 53 | # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax 54 | # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ 55 | # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching 56 | config.disable_monkey_patching! 57 | 58 | # Many RSpec users commonly either run the entire suite or an individual 59 | # file, and it's useful to allow more verbose output when running an 60 | # individual spec file. 61 | if config.files_to_run.one? 62 | # Use the documentation formatter for detailed output, 63 | # unless a formatter has already been configured 64 | # (e.g. via a command-line flag). 65 | config.default_formatter = 'doc' 66 | end 67 | 68 | # Print the 10 slowest examples and example groups at the 69 | # end of the spec run, to help surface which specs are running 70 | # particularly slow. 71 | config.profile_examples = 10 72 | 73 | # Run specs in random order to surface order dependencies. If you find an 74 | # order dependency and want to debug it, you can fix the order by providing 75 | # the seed, which is printed after each run. 76 | # --seed 1234 77 | config.order = :random 78 | 79 | # Seed global randomization in this process using the `--seed` CLI option. 80 | # Setting this allows you to use `--seed` to deterministically reproduce 81 | # test failures related to randomization by passing the same `--seed` value 82 | # as the one that triggered the failure. 83 | Kernel.srand config.seed 84 | =end 85 | end 86 | -------------------------------------------------------------------------------- /test/controllers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TristanToye/rails-4-boilerplate/03db56b5e3a77987af0a35908282014e9fd2e068/test/controllers/.keep -------------------------------------------------------------------------------- /test/fixtures/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TristanToye/rails-4-boilerplate/03db56b5e3a77987af0a35908282014e9fd2e068/test/fixtures/.keep -------------------------------------------------------------------------------- /test/helpers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TristanToye/rails-4-boilerplate/03db56b5e3a77987af0a35908282014e9fd2e068/test/helpers/.keep -------------------------------------------------------------------------------- /test/integration/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TristanToye/rails-4-boilerplate/03db56b5e3a77987af0a35908282014e9fd2e068/test/integration/.keep -------------------------------------------------------------------------------- /test/mailers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TristanToye/rails-4-boilerplate/03db56b5e3a77987af0a35908282014e9fd2e068/test/mailers/.keep -------------------------------------------------------------------------------- /test/models/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TristanToye/rails-4-boilerplate/03db56b5e3a77987af0a35908282014e9fd2e068/test/models/.keep -------------------------------------------------------------------------------- /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/TristanToye/rails-4-boilerplate/03db56b5e3a77987af0a35908282014e9fd2e068/vendor/assets/javascripts/.keep -------------------------------------------------------------------------------- /vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TristanToye/rails-4-boilerplate/03db56b5e3a77987af0a35908282014e9fd2e068/vendor/assets/stylesheets/.keep --------------------------------------------------------------------------------