├── .dockerignore ├── .env.example ├── .gitignore ├── .rspec ├── .rubocop.yml ├── .ruby-version ├── Dockerfile ├── Gemfile ├── Gemfile.lock ├── Guardfile ├── LICENSE.txt ├── Procfile ├── README.md ├── Rakefile ├── app ├── assets │ ├── images │ │ ├── new_styles_folder.png │ │ └── sassish.png │ ├── javascripts │ │ ├── application.js │ │ ├── bootstrap.js.coffee │ │ └── main.js.coffee │ └── stylesheets │ │ ├── application-welcome.css │ │ ├── application.css │ │ ├── bootstrap_and_overrides.css.less │ │ ├── common │ │ └── .gitkeep │ │ ├── main │ │ ├── base │ │ │ ├── _forms.sass │ │ │ ├── _globals.sass │ │ │ ├── _icons.sass │ │ │ ├── _typography.sass │ │ │ └── _utils.sass │ │ ├── core │ │ │ ├── _colors.sass │ │ │ ├── _mixins.sass │ │ │ └── _variables.sass │ │ ├── index.sass │ │ └── styles │ │ │ └── .keep │ │ └── welcome │ │ ├── cover.css │ │ └── test.sass ├── controllers │ ├── application_controller.rb │ ├── concerns │ │ └── .keep │ ├── dashboard_controller.rb │ └── welcome_controller.rb ├── helpers │ └── application_helper.rb ├── mailers │ └── .keep ├── models │ ├── .keep │ ├── ability.rb │ ├── concerns │ │ └── .keep │ └── user.rb ├── views │ ├── devise │ │ ├── confirmations │ │ │ └── new.html.haml │ │ ├── mailer │ │ │ ├── confirmation_instructions.html.haml │ │ │ ├── reset_password_instructions.html.haml │ │ │ └── unlock_instructions.html.haml │ │ ├── passwords │ │ │ ├── edit.html.haml │ │ │ └── new.html.haml │ │ ├── registrations │ │ │ ├── edit.html.haml │ │ │ └── new.html.haml │ │ ├── sessions │ │ │ ├── _sign_in_form.html.haml │ │ │ └── new.html.haml │ │ ├── shared │ │ │ └── _links.haml │ │ └── unlocks │ │ │ └── new.html.haml │ ├── layouts │ │ ├── _messages.html.haml │ │ ├── _navigation.html.haml │ │ ├── _navigation_links.html.erb │ │ ├── application.html.haml │ │ ├── root.html.haml │ │ └── welcome.html.haml │ ├── partials │ │ └── _analytics_scripts.html.haml │ └── welcome │ │ └── index.html.haml └── workers │ └── my_worker.rb ├── bin ├── bundle ├── rails └── rake ├── config.ru ├── config ├── application.rb ├── boot.rb ├── environment.rb ├── environments │ ├── development.rb │ ├── production.rb │ └── test.rb ├── initializers │ ├── assets.rb │ ├── backtrace_silencers.rb │ ├── cookies_serializer.rb │ ├── devise.rb │ ├── filter_parameter_logging.rb │ ├── inflections.rb │ ├── mime_types.rb │ ├── rack_profiler.rb │ ├── sassish.rb │ ├── security_headers.rb │ ├── session_store.rb │ ├── shog.rb │ ├── sidekiq.rb │ ├── simple_form.rb │ ├── simple_form_bootstrap.rb │ └── wrap_parameters.rb ├── locales │ ├── devise.en.yml │ ├── en.bootstrap.yml │ ├── en.yml │ └── simple_form.en.yml ├── mongoid.yml.example ├── routes.rb ├── secrets.yml.example └── unicorn.rb ├── contributors.txt ├── custom_plan.rb ├── db └── seeds.rb ├── deploy └── kubernetes │ ├── docker-compose-kubernetes.yml │ ├── mongo-pod.json │ ├── mongo-service.json │ ├── redis-pod.json │ ├── redis-service.json │ ├── webapp-rc-version2.yml │ ├── webapp-rc.yml │ ├── webapp-service.yml │ └── worker-rc.yml ├── docker-compose.yml ├── lib ├── assets │ └── .keep ├── generators │ └── rails │ │ └── precompiled_stylesheet_generator.rb ├── sassish │ ├── sassish.rb │ └── sassish │ │ ├── engine.rb │ │ ├── extensions │ │ └── generators │ │ │ ├── sass │ │ │ └── assets │ │ │ │ └── assets_generator.rb │ │ │ └── scss │ │ │ └── assets │ │ │ └── assets_generator.rb │ │ └── view_helper.rb ├── tasks │ ├── .keep │ └── code_quality.rake └── templates │ └── haml │ └── scaffold │ └── _form.html.haml ├── log └── .keep ├── public ├── 404.html ├── 422.html ├── 500.html ├── favicon.ico └── robots.txt ├── spec ├── cassettes │ └── Welcome_Page │ │ ├── do_the_ping.yml │ │ └── with_VCR │ │ └── do_the_ping.yml ├── factories │ └── users.rb ├── features │ ├── session_spec.rb │ └── welcome_spec.rb ├── helpers │ └── action_view_spec.rb ├── lib │ ├── sassish_generator_spec.rb │ ├── sassish_spec.rb │ └── scaffold_generator_spec.rb ├── rails_helper.rb └── spec_helper.rb ├── vendor └── assets │ ├── javascripts │ └── .keep │ └── stylesheets │ └── .keep └── zeus.json /.dockerignore: -------------------------------------------------------------------------------- 1 | # Compiled source # 2 | ################### 3 | *.com 4 | *.class 5 | *.dll 6 | *.exe 7 | *.o 8 | *.so 9 | 10 | # Packages # 11 | ############ 12 | # it's better to unpack these files and commit the raw source 13 | # git has its own built in compression methods 14 | *.7z 15 | *.dmg 16 | *.gz 17 | *.iso 18 | *.jar 19 | *.rar 20 | *.tar 21 | *.zip 22 | 23 | # OS generated files # 24 | ###################### 25 | .DS_Store 26 | .DS_Store? 27 | ._* 28 | .Spotlight-V100 29 | .Trashes 30 | Icon? 31 | ehthumbs.db 32 | Thumbs.db 33 | 34 | #Rails specific stuff 35 | config/database.yml 36 | config/env.yml 37 | config/app_config.yml 38 | config/mongoid.yml 39 | 40 | *.log 41 | tmp/ 42 | *.sql 43 | *.sqlite 44 | *.sqlite3 45 | *.sqlite3-journal 46 | .rvmrc 47 | public/system 48 | public/spree 49 | public/uploads 50 | /public/system* 51 | 52 | .idea/ 53 | .sass-cache/ 54 | .bundle/ 55 | .jhw-cache/ 56 | 57 | # Secrets 58 | config/secrets.yml 59 | .env 60 | .env.test 61 | .env.local 62 | .env.staging 63 | 64 | # Simplecov 65 | coverage/ 66 | 67 | ## UNIX TEMP FILES 68 | *~ 69 | 70 | ## GIT 71 | .git 72 | 73 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | # ENV File, if you want to set an env file by a specific environment use: 2 | # .env. 3 | SECRET_CAT_KEY=YOURSECRETKEYGOESHERE 4 | SECRET_KEY_BASE=YOUR_PRODUCTION_KEY_BASE_GOES_HERE 5 | -------------------------------------------------------------------------------- /.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 | # Compiled source # 8 | ################### 9 | *.com 10 | *.class 11 | *.dll 12 | *.exe 13 | *.o 14 | *.so 15 | 16 | # Packages # 17 | ############ 18 | # it's better to unpack these files and commit the raw source 19 | # git has its own built in compression methods 20 | *.7z 21 | *.dmg 22 | *.gz 23 | *.iso 24 | *.jar 25 | *.rar 26 | *.tar 27 | *.zip 28 | 29 | # OS generated files # 30 | ###################### 31 | .DS_Store 32 | .DS_Store? 33 | ._* 34 | .Spotlight-V100 35 | .Trashes 36 | Icon? 37 | ehthumbs.db 38 | Thumbs.db 39 | 40 | #Rails specific stuff 41 | config/database.yml 42 | config/env.yml 43 | config/app_config.yml 44 | config/mongoid.yml 45 | 46 | *.log 47 | tmp/ 48 | *.sql 49 | *.sqlite 50 | *.sqlite3 51 | *.sqlite3-journal 52 | .rvmrc 53 | public/system 54 | public/spree 55 | public/uploads 56 | /public/system* 57 | 58 | .idea/ 59 | .sass-cache/ 60 | .bundle/ 61 | .jhw-cache/ 62 | 63 | # Secrets 64 | config/secrets.yml 65 | .env 66 | .env.test 67 | .env.local 68 | .env.staging 69 | 70 | # Simplecov 71 | coverage/ 72 | 73 | ## UNIX TEMP FILES 74 | *~ 75 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --require spec_helper 3 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | AllCops: 2 | RunRailsCops: true 3 | Include: 4 | - '**/Rakefile' 5 | - '**/config.ru' 6 | Exclude: 7 | - 'db/**/*' 8 | - 'config/**/*' 9 | - 'tmp/**/*' 10 | - 'script/**/*' 11 | - !ruby/regexp /old_and_unused\.rb$/ 12 | Metrics/LineLength: 13 | Max: 200 14 | Metrics/AbcSize: 15 | # The ABC size is a calculated magnitude, so this number can be a Fixnum or 16 | # a Float. 17 | Max: 17 18 | -------------------------------------------------------------------------------- /.ruby-version: -------------------------------------------------------------------------------- 1 | 2.2.2 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ruby:2.2.2 2 | # Install dependencies. 3 | RUN apt-get update -qq && apt-get install -y build-essential libpq-dev 4 | # Setup app directory. 5 | RUN mkdir /myapp 6 | WORKDIR /myapp 7 | # Copy the Gemfile and Gemfile.lock into the image and install gems before the project is copied, 8 | # this is to avoid do bundle install every time some project file change. 9 | COPY Gemfile /myapp/Gemfile 10 | COPY Gemfile.lock /myapp/Gemfile.lock 11 | RUN bundle install --without development test doc --jobs=4 12 | # Everything up to here was cached. This includes the bundle install, unless the Gemfiles changed. 13 | # Now copy the app into the image. 14 | ADD . /myapp 15 | # Cleanup 16 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 17 | # Expose unicorn port 8080 18 | EXPOSE 8080 19 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | ruby '2.2.2' 4 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 5 | gem 'rails', '4.2.3' 6 | # Use SCSS for stylesheets 7 | gem 'sass-rails', '~> 5.0.1' 8 | # Use Uglifier as compressor for JavaScript assets 9 | gem 'uglifier', '>= 2.7.1' 10 | # Use CoffeeScript for .js.coffee assets and views 11 | gem 'coffee-rails', '~> 4.1.0' 12 | # See https://github.com/sstephenson/execjs#readme for more supported runtimes 13 | # gem 'therubyracer', platforms: :ruby 14 | # Use haml 15 | gem 'haml' 16 | gem 'less-rails' 17 | gem 'therubyracer' 18 | 19 | # Use jquery as the JavaScript library 20 | gem 'jquery-rails' 21 | # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks 22 | gem 'turbolinks' 23 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 24 | gem 'jbuilder', '~> 2.2.8' 25 | # bundle exec rake doc:rails generates the API under doc/api. 26 | gem 'sdoc', '~> 0.4.1', group: :doc 27 | #gem 'foundation-rails', '5.4.3.1' 28 | gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git' 29 | gem 'simple_form' 30 | 31 | gem 'awesome_print', git: 'https://github.com/michaeldv/awesome_print' 32 | gem "mongoid", "~> 4.0.0" 33 | gem 'devise' 34 | gem 'mongoid_search' 35 | gem 'will_paginate_mongoid' 36 | gem 'cancancan', '~> 1.10.1' 37 | gem 'secure_headers' 38 | gem 'autoprefixer-rails' 39 | gem 'sidekiq', '~> 3.1.4' 40 | 41 | 42 | group :development do 43 | gem 'guard' 44 | gem 'haml-rails' # only in dev, because haml-rails adds the generators 45 | gem 'quiet_assets' 46 | gem 'rails_layout' 47 | gem 'bullet' 48 | gem 'meta_request' 49 | gem 'shog' 50 | # For supporting flamegraph without errors 51 | # see here: https://github.com/SamSaffron/flamegraph/blob/master/lib/flamegraph.rb#L5 52 | gem 'stackprof' 53 | gem 'rack-mini-profiler', require: false 54 | gem 'flamegraph' 55 | # gems for inspecting code qualitty 56 | gem 'i18n-tasks', '~> 0.7.12' 57 | gem 'rails_best_practices', require: false 58 | gem 'inch', require: false 59 | gem 'guard-inch' 60 | gem 'rubocop', require: false 61 | gem 'guard-rubocop' 62 | gem 'rubycritic', require: false 63 | gem 'guard-rubycritic' 64 | gem 'brakeman-min', require: false 65 | end 66 | 67 | group :development, :test do 68 | gem 'jazz_hands', github: 'jkrmr/jazz_hands' 69 | # If you use gems that require environment variables to be set before they are loaded, 70 | # then list dotenv-rails in the Gemfile before those other gems and require dotenv/rails-now. 71 | # gem 'dotenv-rails', :require => 'dotenv/rails-now' 72 | # gem 'gem-that-requires-env-variables' 73 | gem 'dotenv-rails' 74 | end 75 | 76 | group :test do 77 | # [ERROR] The 'truncation' strategy does not exist [...] Available strategies: truncation 78 | # As a temporary workaround, including mongoid-tree in your Gemfile solves it for now. 79 | gem 'mongoid-tree', :require => 'mongoid/tree' 80 | gem 'simplecov' 81 | gem 'simplecov-html' 82 | gem 'vcr' 83 | gem 'webmock' 84 | gem 'faker' 85 | gem 'factory_girl_rails' 86 | gem 'rspec-rails', '~> 3.2.1' 87 | gem 'rspec-support', '~> 3.2.2' 88 | gem 'capybara' 89 | gem 'launchy' 90 | gem 'shoulda-matchers' 91 | gem 'poltergeist' 92 | gem 'capybara-screenshot' 93 | gem 'database_cleaner' 94 | gem 'mongoid-rspec' 95 | gem 'ammeter' 96 | end 97 | 98 | group :production do 99 | gem 'rails_12factor' 100 | gem 'newrelic_rpm' 101 | gem 'unicorn' 102 | end 103 | 104 | # Use ActiveModel has_secure_password 105 | # gem 'bcrypt', '~> 3.1.7' 106 | 107 | # Use unicorn as the app server 108 | # gem 'unicorn' 109 | 110 | # Use Capistrano for deployment 111 | # gem 'capistrano-rails', group: :development 112 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GIT 2 | remote: git://github.com/jkrmr/jazz_hands.git 3 | revision: 5d672e52772d9abf4064260186556fa963a75604 4 | specs: 5 | jazz_hands (1.0.0) 6 | awesome_print (~> 1.2) 7 | hirb (~> 0.7) 8 | pry (~> 0.10) 9 | pry-byebug (~> 2.0) 10 | pry-coolline (~> 0.2) 11 | pry-doc (~> 0.4) 12 | pry-git (~> 0.2) 13 | pry-rails (~> 0.3) 14 | pry-remote (~> 0.1) 15 | pry-stack_explorer (~> 0.4) 16 | railties (>= 3.0, < 5.0) 17 | 18 | GIT 19 | remote: git://github.com/seyhunak/twitter-bootstrap-rails.git 20 | revision: 935f53bb55ef736260fa2ef04e29da2fc3fb2b3f 21 | specs: 22 | twitter-bootstrap-rails (3.2.1) 23 | actionpack (>= 3.1) 24 | execjs (>= 2.2.2, >= 2.2) 25 | less-rails (>= 2.5.0) 26 | railties (>= 3.1) 27 | 28 | GIT 29 | remote: https://github.com/michaeldv/awesome_print 30 | revision: d8aeb66b4b03dfb2cc1aec4e3187ced2f826d11f 31 | specs: 32 | awesome_print (1.6.2) 33 | 34 | GEM 35 | remote: https://rubygems.org/ 36 | specs: 37 | abstract_type (0.0.7) 38 | actionmailer (4.2.3) 39 | actionpack (= 4.2.3) 40 | actionview (= 4.2.3) 41 | activejob (= 4.2.3) 42 | mail (~> 2.5, >= 2.5.4) 43 | rails-dom-testing (~> 1.0, >= 1.0.5) 44 | actionpack (4.2.3) 45 | actionview (= 4.2.3) 46 | activesupport (= 4.2.3) 47 | rack (~> 1.6) 48 | rack-test (~> 0.6.2) 49 | rails-dom-testing (~> 1.0, >= 1.0.5) 50 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 51 | actionview (4.2.3) 52 | activesupport (= 4.2.3) 53 | builder (~> 3.1) 54 | erubis (~> 2.7.0) 55 | rails-dom-testing (~> 1.0, >= 1.0.5) 56 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 57 | activejob (4.2.3) 58 | activesupport (= 4.2.3) 59 | globalid (>= 0.3.0) 60 | activemodel (4.2.3) 61 | activesupport (= 4.2.3) 62 | builder (~> 3.1) 63 | activerecord (4.2.3) 64 | activemodel (= 4.2.3) 65 | activesupport (= 4.2.3) 66 | arel (~> 6.0) 67 | activesupport (4.2.3) 68 | i18n (~> 0.7) 69 | json (~> 1.7, >= 1.7.7) 70 | minitest (~> 5.1) 71 | thread_safe (~> 0.3, >= 0.3.4) 72 | tzinfo (~> 1.1) 73 | adamantium (0.2.0) 74 | ice_nine (~> 0.11.0) 75 | memoizable (~> 0.4.0) 76 | addressable (2.3.8) 77 | ammeter (1.1.2) 78 | activesupport (>= 3.0) 79 | railties (>= 3.0) 80 | rspec-rails (>= 2.2) 81 | arel (6.0.0) 82 | ast (2.0.0) 83 | astrolabe (1.3.0) 84 | parser (>= 2.2.0.pre.3, < 3.0) 85 | autoprefixer-rails (5.2.1) 86 | execjs 87 | json 88 | axiom-types (0.1.1) 89 | descendants_tracker (~> 0.0.4) 90 | ice_nine (~> 0.11.0) 91 | thread_safe (~> 0.3, >= 0.3.1) 92 | bcrypt (3.1.10) 93 | binding_of_caller (0.7.2) 94 | debug_inspector (>= 0.0.1) 95 | brakeman-min (3.0.5) 96 | multi_json (~> 1.2) 97 | ruby2ruby (~> 2.1.1) 98 | ruby_parser (~> 3.7.0) 99 | bson (3.1.1) 100 | builder (3.2.2) 101 | bullet (4.14.7) 102 | activesupport (>= 3.0.0) 103 | uniform_notifier (~> 1.9.0) 104 | byebug (3.5.1) 105 | columnize (~> 0.8) 106 | debugger-linecache (~> 1.2) 107 | slop (~> 3.6) 108 | callsite (0.0.11) 109 | cancancan (1.10.1) 110 | capybara (2.4.4) 111 | mime-types (>= 1.16) 112 | nokogiri (>= 1.3.3) 113 | rack (>= 1.0.0) 114 | rack-test (>= 0.5.4) 115 | xpath (~> 2.0) 116 | capybara-screenshot (1.0.9) 117 | capybara (>= 1.0, < 3) 118 | launchy 119 | celluloid (0.17.0) 120 | bundler 121 | celluloid-essentials 122 | celluloid-extras 123 | celluloid-fsm 124 | celluloid-pool 125 | celluloid-supervision 126 | dotenv 127 | nenv 128 | rspec-logsplit (>= 0.1.2) 129 | timers (~> 4.0.0) 130 | celluloid-essentials (0.20.1.1) 131 | bundler 132 | dotenv 133 | nenv 134 | rspec-logsplit (>= 0.1.2) 135 | timers (~> 4.0.0) 136 | celluloid-extras (0.20.0) 137 | bundler 138 | dotenv 139 | nenv 140 | rspec-logsplit (>= 0.1.2) 141 | timers (~> 4.0.0) 142 | celluloid-fsm (0.20.0) 143 | bundler 144 | dotenv 145 | nenv 146 | rspec-logsplit (>= 0.1.2) 147 | timers (~> 4.0.0) 148 | celluloid-pool (0.20.0) 149 | bundler 150 | dotenv 151 | nenv 152 | rspec-logsplit (>= 0.1.2) 153 | timers (~> 4.0.0) 154 | celluloid-supervision (0.20.0) 155 | bundler 156 | dotenv 157 | nenv 158 | rspec-logsplit (>= 0.1.2) 159 | timers (~> 4.0.0) 160 | cliver (0.3.2) 161 | code_analyzer (0.4.5) 162 | sexp_processor 163 | coderay (1.1.0) 164 | coercible (1.0.0) 165 | descendants_tracker (~> 0.0.1) 166 | coffee-rails (4.1.0) 167 | coffee-script (>= 2.2.0) 168 | railties (>= 4.0.0, < 5.0) 169 | coffee-script (2.4.1) 170 | coffee-script-source 171 | execjs 172 | coffee-script-source (1.9.1.1) 173 | colored (1.2) 174 | columnize (0.9.0) 175 | commonjs (0.2.7) 176 | concord (0.1.5) 177 | adamantium (~> 0.2.0) 178 | equalizer (~> 0.0.9) 179 | connection_pool (2.2.0) 180 | coolline (0.5.0) 181 | unicode_utils (~> 1.4) 182 | crack (0.4.2) 183 | safe_yaml (~> 1.0.0) 184 | database_cleaner (1.4.1) 185 | debug_inspector (0.0.2) 186 | debugger-linecache (1.2.0) 187 | descendants_tracker (0.0.4) 188 | thread_safe (~> 0.3, >= 0.3.1) 189 | devise (3.5.1) 190 | bcrypt (~> 3.0) 191 | orm_adapter (~> 0.1) 192 | railties (>= 3.2.6, < 5) 193 | responders 194 | thread_safe (~> 0.1) 195 | warden (~> 1.2.3) 196 | diff-lcs (1.2.5) 197 | diffy (3.0.7) 198 | docile (1.1.5) 199 | dotenv (2.0.2) 200 | dotenv-rails (2.0.2) 201 | dotenv (= 2.0.2) 202 | railties (~> 4.0) 203 | easy_translate (0.5.0) 204 | json 205 | thread 206 | thread_safe 207 | equalizer (0.0.11) 208 | erubis (2.7.0) 209 | execjs (2.5.2) 210 | factory_girl (4.5.0) 211 | activesupport (>= 3.0.0) 212 | factory_girl_rails (4.5.0) 213 | factory_girl (~> 4.5.0) 214 | railties (>= 3.0.0) 215 | faker (1.4.3) 216 | i18n (~> 0.5) 217 | fast-stemmer (1.0.2) 218 | fast_stack (0.1.0) 219 | rake 220 | rake-compiler 221 | ffi (1.9.10) 222 | flamegraph (0.1.0) 223 | fast_stack 224 | flay (2.4.0) 225 | ruby_parser (~> 3.0) 226 | sexp_processor (~> 4.0) 227 | flog (4.2.1) 228 | ruby_parser (~> 3.1, > 3.1.0) 229 | sexp_processor (~> 4.4) 230 | formatador (0.2.5) 231 | git-version-bump (0.15.1) 232 | globalid (0.3.5) 233 | activesupport (>= 4.1.0) 234 | grit (2.5.0) 235 | diff-lcs (~> 1.1) 236 | mime-types (~> 1.15) 237 | posix-spawn (~> 0.3.6) 238 | guard (2.12.8) 239 | formatador (>= 0.2.4) 240 | listen (>= 2.7, <= 4.0) 241 | lumberjack (~> 1.0) 242 | nenv (~> 0.1) 243 | notiffany (~> 0.0) 244 | pry (>= 0.9.12) 245 | shellany (~> 0.0) 246 | thor (>= 0.18.1) 247 | guard-inch (0.1.0) 248 | guard 249 | inch 250 | guard-rubocop (1.2.0) 251 | guard (~> 2.0) 252 | rubocop (~> 0.20) 253 | guard-rubycritic (1.4.0) 254 | guard (~> 2.6) 255 | rubycritic (~> 1.4) 256 | haml (4.0.6) 257 | tilt 258 | haml-rails (0.9.0) 259 | actionpack (>= 4.0.1) 260 | activesupport (>= 4.0.1) 261 | haml (>= 4.0.6, < 5.0) 262 | html2haml (>= 1.0.1) 263 | railties (>= 4.0.1) 264 | highline (1.7.2) 265 | hirb (0.7.3) 266 | hitimes (1.2.2) 267 | html2haml (2.0.0) 268 | erubis (~> 2.7.0) 269 | haml (~> 4.0.0) 270 | nokogiri (~> 1.6.0) 271 | ruby_parser (~> 3.5) 272 | i18n (0.7.0) 273 | i18n-tasks (0.7.13) 274 | activesupport 275 | easy_translate (>= 0.5.0) 276 | erubis 277 | highline 278 | i18n 279 | slop (~> 3.5) 280 | term-ansicolor 281 | terminal-table 282 | ice_nine (0.11.1) 283 | inch (0.6.3) 284 | pry 285 | sparkr (>= 0.2.0) 286 | term-ansicolor 287 | yard (~> 0.8.7.5) 288 | jbuilder (2.2.16) 289 | activesupport (>= 3.0.0, < 5) 290 | multi_json (~> 1.2) 291 | jquery-rails (4.0.4) 292 | rails-dom-testing (~> 1.0) 293 | railties (>= 4.2.0) 294 | thor (>= 0.14, < 2.0) 295 | json (1.8.3) 296 | kgio (2.9.3) 297 | launchy (2.4.3) 298 | addressable (~> 2.3) 299 | less (2.6.0) 300 | commonjs (~> 0.2.7) 301 | less-rails (2.7.0) 302 | actionpack (>= 4.0) 303 | less (~> 2.6.0) 304 | sprockets (> 2, < 4) 305 | tilt 306 | libv8 (3.16.14.7) 307 | listen (3.0.1) 308 | rb-fsevent (>= 0.9.3) 309 | rb-inotify (>= 0.9) 310 | loofah (2.0.2) 311 | nokogiri (>= 1.5.9) 312 | lumberjack (1.0.9) 313 | mail (2.6.3) 314 | mime-types (>= 1.16, < 3) 315 | memoizable (0.4.2) 316 | thread_safe (~> 0.3, >= 0.3.1) 317 | meta_request (0.3.4) 318 | callsite (~> 0.0, >= 0.0.11) 319 | rack-contrib (~> 1.1) 320 | railties (>= 3.0.0, < 5.0.0) 321 | method_source (0.8.2) 322 | mime-types (1.25.1) 323 | mini_portile (0.6.2) 324 | minitest (5.7.0) 325 | mongoid (4.0.2) 326 | activemodel (~> 4.0) 327 | moped (~> 2.0.0) 328 | origin (~> 2.1) 329 | tzinfo (>= 0.3.37) 330 | mongoid-rspec (2.2.0) 331 | mongoid (~> 4.0.0) 332 | rake 333 | rspec (~> 3.1) 334 | mongoid-tree (2.0.0) 335 | mongoid (>= 4.0, <= 5.0) 336 | mongoid_search (0.3.2) 337 | fast-stemmer (~> 1.0.0) 338 | mongoid (>= 3.0.0) 339 | moped (2.0.6) 340 | bson (~> 3.0) 341 | connection_pool (~> 2.0) 342 | optionable (~> 0.2.0) 343 | multi_json (1.11.1) 344 | nenv (0.2.0) 345 | newrelic_rpm (3.12.0.288) 346 | nokogiri (1.6.6.2) 347 | mini_portile (~> 0.6.0) 348 | notiffany (0.0.6) 349 | nenv (~> 0.1) 350 | shellany (~> 0.0) 351 | optionable (0.2.0) 352 | origin (2.1.1) 353 | orm_adapter (0.5.0) 354 | parser (2.2.2.5) 355 | ast (>= 1.1, < 3.0) 356 | poltergeist (1.6.0) 357 | capybara (~> 2.1) 358 | cliver (~> 0.3.1) 359 | multi_json (~> 1.0) 360 | websocket-driver (>= 0.2.0) 361 | posix-spawn (0.3.11) 362 | powerpack (0.1.1) 363 | procto (0.0.2) 364 | pry (0.10.1) 365 | coderay (~> 1.1.0) 366 | method_source (~> 0.8.1) 367 | slop (~> 3.4) 368 | pry-byebug (2.0.0) 369 | byebug (~> 3.4) 370 | pry (~> 0.10) 371 | pry-coolline (0.2.5) 372 | coolline (~> 0.5) 373 | pry-doc (0.8.0) 374 | pry (~> 0.9) 375 | yard (~> 0.8) 376 | pry-git (0.2.3) 377 | diffy 378 | grit 379 | pry (>= 0.9.8) 380 | pry-rails (0.3.4) 381 | pry (>= 0.9.10) 382 | pry-remote (0.1.8) 383 | pry (~> 0.9) 384 | slop (~> 3.0) 385 | pry-stack_explorer (0.4.9.2) 386 | binding_of_caller (>= 0.7) 387 | pry (>= 0.9.11) 388 | quiet_assets (1.1.0) 389 | railties (>= 3.1, < 5.0) 390 | rack (1.6.4) 391 | rack-contrib (1.3.0) 392 | git-version-bump (~> 0.15) 393 | rack (~> 1.4) 394 | rack-mini-profiler (0.9.3) 395 | rack (>= 1.1.3) 396 | rack-test (0.6.3) 397 | rack (>= 1.0) 398 | rails (4.2.3) 399 | actionmailer (= 4.2.3) 400 | actionpack (= 4.2.3) 401 | actionview (= 4.2.3) 402 | activejob (= 4.2.3) 403 | activemodel (= 4.2.3) 404 | activerecord (= 4.2.3) 405 | activesupport (= 4.2.3) 406 | bundler (>= 1.3.0, < 2.0) 407 | railties (= 4.2.3) 408 | sprockets-rails 409 | rails-deprecated_sanitizer (1.0.3) 410 | activesupport (>= 4.2.0.alpha) 411 | rails-dom-testing (1.0.6) 412 | activesupport (>= 4.2.0.beta, < 5.0) 413 | nokogiri (~> 1.6.0) 414 | rails-deprecated_sanitizer (>= 1.0.1) 415 | rails-html-sanitizer (1.0.2) 416 | loofah (~> 2.0) 417 | rails_12factor (0.0.3) 418 | rails_serve_static_assets 419 | rails_stdout_logging 420 | rails_best_practices (1.15.7) 421 | activesupport 422 | code_analyzer (>= 0.4.3) 423 | colored 424 | erubis 425 | i18n 426 | json 427 | require_all 428 | ruby-progressbar 429 | rails_layout (1.0.26) 430 | rails_serve_static_assets (0.0.4) 431 | rails_stdout_logging (0.0.3) 432 | railties (4.2.3) 433 | actionpack (= 4.2.3) 434 | activesupport (= 4.2.3) 435 | rake (>= 0.8.7) 436 | thor (>= 0.18.1, < 2.0) 437 | rainbow (2.0.0) 438 | raindrops (0.14.0) 439 | rake (10.4.2) 440 | rake-compiler (0.9.5) 441 | rake 442 | rb-fsevent (0.9.5) 443 | rb-inotify (0.9.5) 444 | ffi (>= 0.5.0) 445 | rdoc (4.2.0) 446 | redis (3.2.1) 447 | redis-namespace (1.5.2) 448 | redis (~> 3.0, >= 3.0.4) 449 | reek (1.6.5) 450 | parser (~> 2.2.0.pre.7) 451 | rainbow (>= 1.99, < 3.0) 452 | unparser (~> 0.2.2) 453 | ref (1.0.5) 454 | require_all (1.3.2) 455 | responders (2.1.0) 456 | railties (>= 4.2.0, < 5) 457 | rspec (3.2.0) 458 | rspec-core (~> 3.2.0) 459 | rspec-expectations (~> 3.2.0) 460 | rspec-mocks (~> 3.2.0) 461 | rspec-core (3.2.3) 462 | rspec-support (~> 3.2.0) 463 | rspec-expectations (3.2.1) 464 | diff-lcs (>= 1.2.0, < 2.0) 465 | rspec-support (~> 3.2.0) 466 | rspec-logsplit (0.1.3) 467 | rspec-mocks (3.2.1) 468 | diff-lcs (>= 1.2.0, < 2.0) 469 | rspec-support (~> 3.2.0) 470 | rspec-rails (3.2.3) 471 | actionpack (>= 3.0, < 4.3) 472 | activesupport (>= 3.0, < 4.3) 473 | railties (>= 3.0, < 4.3) 474 | rspec-core (~> 3.2.0) 475 | rspec-expectations (~> 3.2.0) 476 | rspec-mocks (~> 3.2.0) 477 | rspec-support (~> 3.2.0) 478 | rspec-support (3.2.2) 479 | rubocop (0.32.1) 480 | astrolabe (~> 1.3) 481 | parser (>= 2.2.2.5, < 3.0) 482 | powerpack (~> 0.1) 483 | rainbow (>= 1.99.1, < 3.0) 484 | ruby-progressbar (~> 1.4) 485 | ruby-progressbar (1.7.5) 486 | ruby2ruby (2.1.4) 487 | ruby_parser (~> 3.1) 488 | sexp_processor (~> 4.0) 489 | ruby_parser (3.7.0) 490 | sexp_processor (~> 4.1) 491 | rubycritic (1.4.0) 492 | flay (= 2.4.0) 493 | flog (= 4.2.1) 494 | parser (>= 2.2.0, < 3.0) 495 | reek (= 1.6.5) 496 | virtus (~> 1.0) 497 | safe_yaml (1.0.4) 498 | sass (3.4.15) 499 | sass-rails (5.0.3) 500 | railties (>= 4.0.0, < 5.0) 501 | sass (~> 3.1) 502 | sprockets (>= 2.8, < 4.0) 503 | sprockets-rails (>= 2.0, < 4.0) 504 | tilt (~> 1.1) 505 | sdoc (0.4.1) 506 | json (~> 1.7, >= 1.7.7) 507 | rdoc (~> 4.0) 508 | secure_headers (2.2.1) 509 | user_agent_parser 510 | sexp_processor (4.6.0) 511 | shellany (0.0.1) 512 | shog (0.1.5) 513 | colored (~> 1.2) 514 | rails (~> 4.0) 515 | shoulda-matchers (2.8.0) 516 | activesupport (>= 3.0.0) 517 | sidekiq (3.1.4) 518 | celluloid (>= 0.15.2) 519 | connection_pool (>= 2.0.0) 520 | json 521 | redis (>= 3.0.6) 522 | redis-namespace (>= 1.3.1) 523 | simple_form (3.1.0) 524 | actionpack (~> 4.0) 525 | activemodel (~> 4.0) 526 | simplecov (0.10.0) 527 | docile (~> 1.1.0) 528 | json (~> 1.8) 529 | simplecov-html (~> 0.10.0) 530 | simplecov-html (0.10.0) 531 | slop (3.6.0) 532 | sparkr (0.4.1) 533 | sprockets (3.2.0) 534 | rack (~> 1.0) 535 | sprockets-rails (2.3.2) 536 | actionpack (>= 3.0) 537 | activesupport (>= 3.0) 538 | sprockets (>= 2.8, < 4.0) 539 | stackprof (0.2.7) 540 | term-ansicolor (1.3.2) 541 | tins (~> 1.0) 542 | terminal-table (1.4.5) 543 | therubyracer (0.12.2) 544 | libv8 (~> 3.16.14.0) 545 | ref 546 | thor (0.19.1) 547 | thread (0.2.0) 548 | thread_safe (0.3.5) 549 | tilt (1.4.1) 550 | timers (4.0.1) 551 | hitimes 552 | tins (1.5.4) 553 | turbolinks (2.5.3) 554 | coffee-rails 555 | tzinfo (1.2.2) 556 | thread_safe (~> 0.1) 557 | uglifier (2.7.1) 558 | execjs (>= 0.3.0) 559 | json (>= 1.8.0) 560 | unicode_utils (1.4.0) 561 | unicorn (4.9.0) 562 | kgio (~> 2.6) 563 | rack 564 | raindrops (~> 0.7) 565 | uniform_notifier (1.9.0) 566 | unparser (0.2.4) 567 | abstract_type (~> 0.0.7) 568 | adamantium (~> 0.2.0) 569 | concord (~> 0.1.5) 570 | diff-lcs (~> 1.2.5) 571 | equalizer (~> 0.0.9) 572 | parser (~> 2.2.2) 573 | procto (~> 0.0.2) 574 | user_agent_parser (2.2.0) 575 | vcr (2.9.3) 576 | virtus (1.0.5) 577 | axiom-types (~> 0.1) 578 | coercible (~> 1.0) 579 | descendants_tracker (~> 0.0, >= 0.0.3) 580 | equalizer (~> 0.0, >= 0.0.9) 581 | warden (1.2.3) 582 | rack (>= 1.0) 583 | webmock (1.21.0) 584 | addressable (>= 2.3.6) 585 | crack (>= 0.3.2) 586 | websocket-driver (0.5.4) 587 | websocket-extensions (>= 0.1.0) 588 | websocket-extensions (0.1.2) 589 | will_paginate (3.0.7) 590 | will_paginate_mongoid (2.0.1) 591 | mongoid 592 | will_paginate (~> 3.0) 593 | xpath (2.0.0) 594 | nokogiri (~> 1.3) 595 | yard (0.8.7.6) 596 | 597 | PLATFORMS 598 | ruby 599 | 600 | DEPENDENCIES 601 | ammeter 602 | autoprefixer-rails 603 | awesome_print! 604 | brakeman-min 605 | bullet 606 | cancancan (~> 1.10.1) 607 | capybara 608 | capybara-screenshot 609 | coffee-rails (~> 4.1.0) 610 | database_cleaner 611 | devise 612 | dotenv-rails 613 | factory_girl_rails 614 | faker 615 | flamegraph 616 | guard 617 | guard-inch 618 | guard-rubocop 619 | guard-rubycritic 620 | haml 621 | haml-rails 622 | i18n-tasks (~> 0.7.12) 623 | inch 624 | jazz_hands! 625 | jbuilder (~> 2.2.8) 626 | jquery-rails 627 | launchy 628 | less-rails 629 | meta_request 630 | mongoid (~> 4.0.0) 631 | mongoid-rspec 632 | mongoid-tree 633 | mongoid_search 634 | newrelic_rpm 635 | poltergeist 636 | quiet_assets 637 | rack-mini-profiler 638 | rails (= 4.2.3) 639 | rails_12factor 640 | rails_best_practices 641 | rails_layout 642 | rspec-rails (~> 3.2.1) 643 | rspec-support (~> 3.2.2) 644 | rubocop 645 | rubycritic 646 | sass-rails (~> 5.0.1) 647 | sdoc (~> 0.4.1) 648 | secure_headers 649 | shog 650 | shoulda-matchers 651 | sidekiq (~> 3.1.4) 652 | simple_form 653 | simplecov 654 | simplecov-html 655 | stackprof 656 | therubyracer 657 | turbolinks 658 | twitter-bootstrap-rails! 659 | uglifier (>= 2.7.1) 660 | unicorn 661 | vcr 662 | webmock 663 | will_paginate_mongoid 664 | 665 | BUNDLED WITH 666 | 1.10.6 667 | -------------------------------------------------------------------------------- /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 :rubocop, all_on_start: true, notification: true, cli: ['--format', 'html', '-o', 'tmp/rubocop.html'] do 19 | watch(%r{.+\.rb$}) 20 | watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) } 21 | end 22 | 23 | guard 'rubycritic' do 24 | watch(%r{^app/(.+)\.rb$}) 25 | watch(%r{^lib/(.+)\.rb$}) 26 | end 27 | 28 | guard :inch, pedantic: true, all_on_start: true, all_type: :list do 29 | watch(/.+\.rb/) 30 | end 31 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Codescrum 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CODESCRUM RAILS TEMPLATE 2 | 3 | A base template for deploying Rails applications. 4 | 5 | ## ESSENTIAL VERSIONS 6 | 7 | The following versions are very important to keep in mind. We've done this because we think that the Ruby, Rails and ORM type and versions are the ones that apply the most constraints to a starter template. 8 | 9 | - Ruby 2.2.0 10 | 11 | - Rails 4.2.2 12 | 13 | - Mongoid 4.0.2 14 | 15 | Also this template uses [Zeus](https://github.com/burke/zeus) which preloads your Rails app so that your normal development tasks such as console, server, generate, and specs/tests take less than one second. 16 | 17 | You can configure Zeus' settings using the `zeus.json` file located in your Rails root path. 18 | 19 | **Note**: We are not using Spring. If you would like to disable all possible problems by using Spring and Zeus at the same time, consider setting the `DISABLE_SPRING=true` environment variable (place in your `.bashrc` or `.zshrc` file). 20 | 21 | ## INSTALL 22 | 23 | Installing zeus (this template was tested with zeus v0.15.4) 24 | 25 | ```sh 26 | $ gem install zeus -v 0.15.4 27 | ``` 28 | 29 | Copy the example files 30 | 31 | ```sh 32 | $ cp config/mongoid.yml.example config/mongoid.yml 33 | $ cp config/secrets.yml.example config/secrets.yml 34 | $ cp .env.example .env 35 | ``` 36 | 37 | Running Zeus 38 | ```sh 39 | $ zeus start 40 | ``` 41 | 42 | Running Server 43 | ```sh 44 | $ zeus server 45 | ``` 46 | 47 | Running Specs 48 | ```sh 49 | $ zeus rspec spec 50 | ``` 51 | 52 | ### HEROKU INSTALL 53 | 54 | * Set the SECRET_KEY_BASE environment variable (you can generate this using the `rake secret`, it will output a generated token for you, just copy/paste) 55 | 56 | ```sh 57 | heroku config:set SECRET_KEY_BASE=a25...2cefa 58 | ``` 59 | 60 | * Install the Mongoid addon (we’ve selected the free option - MongoLab) 61 | 62 | ```sh 63 | heroku addons:create mongolab:sandbox 64 | ``` 65 | 66 | * Uncomment the heroku deployment hack located at the end of the `config/application.rb` file 67 | 68 | ## TECH EXPLANATIONS 69 | 70 | ### SECURITY 71 | ####Brakeman ([GITHUB REPO](https://github.com/presidentbeef/brakeman)) 72 | Brakeman is a static analysis tool which checks Ruby on Rails applications for security vulnerabilities. 73 | 74 | *usage* 75 | 76 | ```sh 77 | brakeman -o output_file 78 | ``` 79 | 80 | Check the gem's README and instructions on how it reports vulnerabilities (and how to fix them). 81 | #### SecureHeaders ([GITHUB REPO](https://github.com/twitter/secureheaders)) 82 | Security related headers all in one gem, you can find the config file in `config/initializers/security_headers.rb`, The security rules have been loaded on `ApplicationController` class using the `ensure_security_headers` class method. 83 | 84 | The gem will automatically apply several headers that are related to security. This includes: 85 | 86 | ##### Generally supports 87 | - Prevents your content from being framed and potentially clickjacked 88 | - Prevent content type sniffing 89 | - Helps prevent attacks based on MIME-type confusion. 90 | - Cross site scripting heuristic filter for IE/Chrome 91 | - Prevent file downloads opening 92 | - Restrict Adobe Flash Player's access to data 93 | 94 | ##### Strict Transport Security 95 | Is a security feature that lets a web site tell browsers that it should only be communicated with using HTTPS, instead of using HTTP (it forces you to do things the right way on production). 96 | 97 | *Browser compatibility:* 98 | 99 | - IE: 11 100 | - Chrome: > 4 101 | - Firefox: > 4 102 | - Opera: 12 103 | - Safari: 7 104 | 105 | Optional: Learn more about HTTP Strict Transport Security here: 106 | https://goo.gl/ldjc5h 107 | 108 | ##### Content Security Policy 109 | Is an added layer of security that helps to detect and mitigate certain types of attacks, including Cross Site Scripting (XSS) and data injection attacks. These attacks are used for everything from data theft to site defacement or distribution of malware. 110 | 111 | *Browser compatibility:* 112 | 113 | - IE: Edge 114 | - Chrome: > 25 115 | - Firefox: > 24 116 | - Opera: 15 117 | - Safari: 7 118 | 119 | Optional: Learn more about Content Security Policy here: 120 | https://goo.gl/u23dit 121 | | https://goo.gl/wHC9C5 122 | | https://goo.gl/Z8UvAz 123 | 124 | ##### Public Key Pinning 125 | The Public Key Pinning Extension for HTTP (HPKP) is a security feature that tells a web client to associate a specific cryptographic public key with a certain web server to prevent MITM attacks with forged certificates. 126 | 127 | *Browser compatibility:* 128 | 129 | - IE: ? 130 | - Chrome: > 38 131 | - Firefox: > 35 132 | - Opera: ? 133 | - Safari: ? 134 | 135 | *Server Compatibility* 136 | 137 | - NGINX: adding the following line and inserting the appropriate pin-sha256="..." values will enable HPKP on your nginx. This requires the `ngx_http_headers_module` to be installed on your nginx installation (it should be installed by default, as it is a standard nginx module). See more details for this module here: http://nginx.org/en/docs/http/ngx_http_headers_module.html. 138 | 139 | - Apache: adding a line similar to the following to your web server's config will enable HPKP on your Apache. This requires the `mod_headers` module enabled. 140 | 141 | **Important Note**: If you enable the HPKP feature, you **MUST** enable the server side modules for this too, because if not, you will not be able to connect to the server. 142 | 143 | Optional: learn more about the details of HPKP here: 144 | https://goo.gl/yrx3ex 145 | | http://goo.gl/zFnaaW 146 | ### CONFIG 147 | We are using a combined strategy between [secrets](http://guides.rubyonrails.org/4_1_release_notes.html#config-secrets-yml) and [dotenv](https://github.com/bkeepers/dotenv) approaches, you can use a similar approach like Figaro, in fact after almost two years there is still some discussion about what is the best approach for managing your settings and sensitive information (there is an interesting post from Figaro's creator [here](http://www.collectiveidea.com/blog/archives/2013/12/18/the-marriage-of-figaro-and-rails/)). 148 | 149 | Finally, these are our conclusions about the selected approach: 150 | 151 | - Always gitignore your config files (at least those that do not contain *heteromorphic* or *sensitive* data - but it would be an odd case) [*heteromorphic* in this context: configuration settings that don't change depending on the environment, possibly application configuration runtime settings]. 152 | 153 | - It is great that our settings can be managed through a "rich object", it gives us a convenient way for controlling and structuring our information using a set-based approach. 154 | 155 | - In order to be compliant with the [config section](http://12factor.net/config) in the [twelve factor app](http://12factor.net/) methodology, we can also use environment variables (ENV) whenever necessary. `config/secrets.yml` as other YAML files in Rails is passed first through ERB, this behaviour gives us the chance to set our ENV using `dotenv` which allows us to load environment variables from an `.env` file into ENV in the configured environment. 156 | 157 | - Keeping an easy deployment is a priority, and it is clear that using an ENV approach seems to cover this concern, but you can obtain the benefits of an hybrid solution by using a rich object support and ENV approach. Our experience has taught us that the sensitive data and the external integration credentials is a real concern for both the staging and production environments (especially for scenarios with limited control as Heroku), however you can manage this responsibility with ease, in your own servers you always can use capistrano (or similar solutions) for automating the remote installation of the `secrets.yml` file in each application server. On the other hand, you can also configure your application so that it’s compliant with Heroku. This template does not come bundled with capistrano or anything so you can choose what to do, but we recommend that you stick with the ["Store config in the environment" premise on 12factor](http://12factor.net/config). 158 | 159 | To configure this template for a standard Heroku deployment, you just have to add/uncomment a little deployment hack that you can see at the end of `config/application.rb` file (remember that the `secrets.yml` file is gitignored) in order to copy the example files that come with environment variable fetching inside of them via erb. 160 | 161 | - One of the most important things in our context is ‘convention over configuration’, and **secrets** is the default approach (and convention) for managing sensitive information in the Rails community (although we really think a better name would be "app_config"). 162 | 163 | - Secure defaults, the new convention has agreed that the `secret_key_base` (used to verify the integrity of signed cookies) will be stored in the **secrets** file, you can see more info [here](http://guides.rubyonrails.org/upgrading_ruby_on_rails.html#config-secrets-yml) and [here](http://stackoverflow.com/questions/25426940/what-is-the-use-of-secret-key-base-in-rails-4) 164 | 165 | #### Dotenv ([GITHUB REPO](https://github.com/bkeepers/dotenv)) 166 | You can use this integration for configuring your environment variables in the app environment you desire. For now the template has an `.env.example` in which you can establish a common structure for your ENVs, then you can integrate this declarations into the secrets file using an ERB definition: `secret_cat_key: <%= ENV["SECRET_CAT_KEY"] %>`, this way both a file or ENV approach can be used, whichever you select. 167 | ### TESTING 168 | This template follows the RSpec rules mentioned on the [RSpec upgrading documentation](https://www.relishapp.com/rspec/rspec-rails/docs/upgrade#default-helper-files), in that sense we have two config files: 169 | 170 | - `spec_helper`: this file provides an out-of-the-box way to avoid loading Rails for those specs that do not require it. We are using the `--require spec_helper` option inside the `.rspec` file by establishing a non-Rails configuration by default. 171 | 172 | - `rails_helper`: this file provides a configuration space for specs which **do** depend on Rails (in a Rails project, most or all of them). `rails_helper.rb`. `.rspec` file requires `spec_helper.rb` by default, for that reason `rails_helper.rb` does not need to require to `spec_helper.rb` by itself. You can change the default setting to use `--require rails_helper.rb` in your `.rspec` file if you wish. 173 | 174 | If you wonder yourself what happens when you run `zeus rspec` then we have tested that it will load your `rails_helper.rb` file just once. This way when you run your tests you won't have to wait for the `rails_helper.rb` file to be loaded each time. Take into account that zeus sometimes does not reload changes in the pre-forked files, so it is better for you to restart zeus whenever you have made changes to the `spec_helper.rb` or `rails_helper.rb` files to be sure. 175 | 176 | Also, according to the current configuration you don’t need to add any metadata information manually, take into account that newer versions of Rspec ( > 3.0.0) do not do it unless you explicitly specify it, you can find this config line in the `rails_helper.rb` file: `config.infer_spec_type_from_file_location!`. Be aware on how your files are structured, you can find a good explanation on to organize spec files here: [here](https://www.relishapp.com/rspec/rspec-rails/v/3-0/docs/directory-structure). 177 | 178 | #### Capybara & Poltergeist ([GITHUB REPO](https://github.com/teampoltergeist/poltergeist)) 179 | Poltergeist is our chosen driver for Capybara. It allows you to run your Capybara tests on a headless WebKit browser, provided by PhantomJS. We are using this driver in favor of [capybara-webkit](https://github.com/thoughtbot/capybara-webkit) and [selenium](https://github.com/seleniumhq/selenium). 180 | 181 | Selenium is a good tool for enabling automation of web browsers, it applies for automated testing too but it is much slower than **capybara-webkit** and **poltergeist**, since it fires up a whole Firefox browser instance. 182 | 183 | Compared to **capybara-webkit** we can find that **poltergeist** has the following advantages: 184 | 185 | - Sometimes, in **capybara-webkit** *what you see is NOT what you get (perhaps on the interacting scenarios)*, we have had some problems when we use some dynamic graphical interactions (animations, fade-out, fade-in, etc), some of them have been impossible to testing or in the good case for building our tests we have had to make some unpleasant tricks. 186 | 187 | - Poltergeist has much clearer error messages, its debugging and inspection system is so much better, you can easily see if a HTML element is overlapping with another (avoiding to execute some action or event on it) or track your javascript errors. 188 | 189 | - The installation process is easier, even on Linux you can find stable binary releases for PhantomJS. 190 | 191 | - The screenshot feature is more flexible (i.e. customizable). 192 | 193 | - You can inspect network traffic. 194 | 195 | - You have a richer API to trigger native events (e.g. typed keys, mouse, etc) on a specific HTML element. 196 | 197 | ```ruby 198 | element.native.send_key(:Enter) # triggers Enter key 199 | ``` 200 | 201 | At the end, you can customize several options for deploying Poltergeist changing the way how Capybara executes your test suite. 202 | 203 | We recommend that you always try to use version managers for everything you can, such as [phantomenv](https://github.com/boxen/phantomenv). for PhantomJS. 204 | ##### PhantomJS for Linux 205 | you can find an stable release here: 206 | 207 | - [PhantomJS 1.9.7](https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2) (tested on Ubuntu 12.04) 208 | 209 | you can choose the edge (2015-07-02): 210 | 211 | - [PhantomJS 2.0.0](https://s3.amazonaws.com/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2) (tested on Ubuntu 12.04) 212 | - [PhantomJS 2.0.0](https://github.com/bprodoehl/phantomjs/releases/tag/v2.0.0-20150528) for linux 14.04 and 15.04 (not tested) 213 | 214 | you can see the complete discussion [here](https://github.com/ariya/phantomjs/issues/12948) 215 | 216 | ##### PhantomJS for Mac 217 | 218 | - You can install it using *brew* `brew install phantomjs` 219 | - If you want to be in the edge you can install from [here](http://phantomjs.org/download.html) 220 | - If you are using Boxen, you can try (NOT TESTED) [this module](https://github.com/boxen/puppet-phantomjs). 221 | 222 | ##### PhantomJS for Windows 223 | No, close this window...seriously?... sorry for you. 224 | #### Test coverage 225 | Test coverage is provided by the [simplecov gem](https://github.com/colszowka/simplecov), however this integration has some problems with Zeus but we have already dealt with them in this template. You can find more info [here](https://github.com/burke/zeus/wiki/SimpleCov) and [here](https://github.com/burke/zeus/issues/131#issuecomment-64106894), also you can manipulate the way how things are loaded by modifying the `custom_plan.rb` file located in your Rails root path, as we mentioned earlier. 226 | 227 | Similarly, at the beginning of the `rails_helper.rb` file we have configured simplecov to work without zeus too. Finally we can find all the coverage in the `coverage/` folder which is gitignored by default and is updated once the tests have finished running. 228 | 229 | #### Miscellaneous 230 | We have complemented our test suite with some basic stuff we always use like: 231 | 232 | - [VCR](https://github.com/vcr/vcr) records your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests. There is an example spec in the `spec/features/welcome_spec.rb` for you to copy from (because we have bad memory), also you can see more info [here](https://www.relishapp.com/vcr/vcr/v/2-9-0/docs/test-frameworks/usage-with-rspec-metadata) 233 | 234 | - [Faker](https://github.com/stympy/faker) A library for generating fake data such as names, addresses, and phone numbers. 235 | 236 | - [Factory Girl](https://github.com/thoughtbot/factory_girl) factory_girl is a fixtures replacement with a straightforward definition syntax, support for multiple build strategies (saved instances, unsaved instances, attribute hashes, and stubbed objects), and support for multiple factories for the same class (user, admin_user, and so on), including factory inheritance. 237 | 238 | ### CODE QUALITY 239 | We have integrated five (5) powerful gems for checking code quality. 240 | 241 | #### Rubocop ([GITHUB REPO](https://github.com/bbatsov/rubocop)) 242 | A Ruby static code analyzer, based on the community Ruby style guide. You can execute this code inspection process by using the `$ rubocop --format html -o tmp/rubocop.html` command, it will generate a new file `tmp/rubocop.html` in which you can see your “offenses” inside your code. Also, you can find the config rubocop file in `.rubocop.yml`. 243 | 244 | #### Rubycritic ([GITHUB REPO](https://github.com/whitesmith/rubycritic)) 245 | RubyCritic is a gem that wraps around static analysis gems such as [Reek](https://github.com/troessner/reek), [Flay](https://github.com/seattlerb/flay) and [Flog](https://github.com/seattlerb/flog) to provide a quality report of your Ruby code. You can execute this code inspection process by using the `$ rubycritic app` command, it will generate a HTML file set for the code quality report, you can find this in `tmp/rubycritic/overview.html`. 246 | 247 | 248 | #### Rails Best Practices ([GITHUB REPO](https://github.com/railsbp/rails_best_practices)) 249 | It is a code metric tool to check the quality of Rails code. It is a little old fashioned but it could help you with some metrics that are not visible to the others analysers (Rubocop, Rubycritic). 250 | 251 | #### Inch ([GITHUB REPO](https://github.com/rrrene/inch)) 252 | A documentation measurement tool for Ruby, based on YARD. you can generate several documentation reports for your code documentation, execute this code inspection by using the `$ inch` command, however you can also use other options like: `$ inch stats` `$ inch lists` `$ inch suggest` for obtaining a most complete information. You can see a quick 'getting started' guide [here](http://trivelop.de/inch/). 253 | 254 | #### Bullet ([GITHUB REPO](https://github.com/flyerhzm/bullet)) 255 | Bullet helps you to kill N+1 queries and unused eager loading, it will run each time that you execute any request on your web server, you can see either a javascript alert (you can also disable it) or a little report in the logs (or both of them) when a new related issue is found. You can find the config block in the `config/environment/development.rb` file. 256 | 257 | #### Shortcuts 258 | We are using [Guard](https://github.com/guard/guard) for automating the inspection of code changes. Guard is a command line tool to easily handle events on file system modifications. We have integrated Guard with Inch, Rubycritic and Rubocop. If you want to execute this process you can run the `$ guard` command in the root project path. 259 | 260 | If you do not want have a process for monitoring and doing this stuff all the time for you, you can run `$ rake code_quality:check` for running Rubycritic, Rail Best Practices, Inch and Rubocop inspections all at once whenever you want. 261 | 262 | ### PERFORMANCE 263 | Improving our application’s performance is a very important thing, in the previous section (**CODE QUALITY**) we have included the **Bullet** gem, you can use it for improving the performance a lot. However, we have included other gems which are very useful for tracking your load times as well. 264 | 265 | #### Rack Mini Profiler ([GITHUB PROJECT](https://github.com/MiniProfiler/rack-mini-profiler)) 266 | It is a middleware that displays speed badge for every html page. Designed to work both in production and in development (it is configured in the development environment by default). If you experiment some problems with the caching behaviour you can see this [section](https://github.com/MiniProfiler/rack-mini-profiler#caching-behavior). On the other hand, it could become annoying, so you can disable it by following these instructions: 267 | 268 | 1. Go to the rack mini profiler initializer located in: `config/initializers/rack_profiler.rb` 269 | 2. Comment the initialization line in this file (the only one there is). 270 | 271 | You can also configure a lot of settings for this gem, see the [redame](https://github.com/MiniProfiler/rack-mini-profiler#configuration-options) for more information. 272 | #### Flamegraph ([GITHUB PROJECT](https://github.com/brendangregg/FlameGraph)) 273 | It is a stack trace visualizer for Ruby 2.0, flamegraph support is built into rack-mini-profiler, just require this gem and you should be good to go. you only need to add **?pp=flamegraph** at the end of your *query string* 274 | 275 | ### DEBUGGING & LOGGING 276 | Debugging is a pretty important process for developing an application, we have integrated a [jazz_hands](https://github.com/jkrmr/jazz_hands) gem, it is an opinionated set of console-related gems and a bit of glue (having [Pry](https://github.com/pry/pry) as its core): 277 | 278 | * [**Pry**][pry] for a powerful shell alternative to IRB. 279 | * [**Awesome Print**][awesome_print] for stylish pretty print. 280 | * [**Hirb**][hirb] for tabular collection output. 281 | * [**Pry Rails**][pry-rails] for additional commands (`show-routes`, 282 | `show-models`, `show-middleware`) in the Rails console. 283 | * [**Pry Doc**][pry-doc] to browse Ruby source, including C, directly from the 284 | console. 285 | * [**Pry Git**][pry-git] to teach the console about git. Diffs, blames, and 286 | commits on methods and classes, not just files. 287 | * [**Pry Remote**][pry-remote] to connect remotely to a Pry console. 288 | * [**Pry Byebug**][pry-byebug] to turn the console into a simple debugger. 289 | * [**Pry Stack Explorer**][pry-stack_explorer] to navigate the call stack and 290 | frames. 291 | * [**Coolline**][coolline] and [**Coderay**][coderay] for syntax highlighting as 292 | you type. _Optional. MRI 2.0.0+ only_ 293 | 294 | You can see how to use Pry [here](http://www.sitepoint.com/rubyists-time-pry-irb/) there are amazing tricks and commands that you can utilize for inspecting your code, even make a [RDD - REPL Driven Development](https://www.youtube.com/watch?v=D9j_Mf91M0I). 295 | ### FRONTEND 296 | 297 | #### THE SASS WAY (Sassish) 298 | 299 | We want to integrate a new way for structuring and generating our stylesheet resources in Rails. For that reason we have designed **Sassish**, and we will introduce you to it. 300 | 301 | Sassish (we are thinking about changing its name, also we are thinking in bundling this piece of code in a gem as well) helps you with how the style files are organized and how these are loaded, its approach is an hybrid combination between both the traditional assets precompile philosophy and the benefits of sass' features. 302 | 303 | The main idea is to simplify the development process by improving the organization, reusability and loading of the stylesheet resources, mitigating many issues that we've seen (it will help you for including an [OOCSS](http://www.slideshare.net/stubbornella/object-oriented-css) philosophy in the future). 304 | 305 | As you can see in the image below, we have two macro-levels of organization (you can choose only one level if you want), the first level solves the problem for including more than one CSS framework (e.g. Bootstrap vs Foundation) or UI kit (i.e. third party CSS components) by using multiple Rails layouts, in this case we have two segmentations:`application` and `application-welcome`. 306 | 307 | ![alt tag](https://raw.githubusercontent.com/Johaned/rails-template/master/app/assets/images/sassish.png) 308 | 309 | 310 | The second level is the most important one, it defines a new structure in which you have two kind of style resource areas, the first one allows you to define your general style (the common style inherited from the specific rails layout, in this case it is the **main** layout associated with the `application.css` manifest), all sass files defined here will be loaded in each view associated with the **main** layout. Take into account that all common rendered CSS should be included in the **base** folder, on the other hand, the **core** folder only should be used for reusable components applying a more object oriented philosophy (you can read more info about this [here](http://www.smashingmagazine.com/2011/12/12/an-introduction-to-object-oriented-css-oocss/) and [here](http://thesassway.com/intermediate/using-object-oriented-css-with-sass)). 311 | 312 | The **styles** folder defines an automatic way for loading your stylesheets according to a specific controller. Suppose that you have the following distribution: 313 | 314 | ![alt tag](https://raw.githubusercontent.com/Johaned/rails-template/master/app/assets/images/new_styles_folder.png) 315 | 316 | 317 | And suppose that you are requesting a view which is linked to the `UserController` (which uses the **main** layout), then **Sassish** will automatically include both **base** and **users.sass** style files, it means that all remaining files inside the **styles** folder won’t be included, which improves performance. 318 | 319 | However you can also use a **Sassish** helper method named `add_sassish_style` for explicitly including any number of style files that you may want for a specific view. For example: 320 | 321 | ```haml 322 | - add_sassish_style 'main/styles/non-controller', 'any/other/file' # adds non-controller.sass and another file you have lying around only to this view 323 | %h2= t(".sign_in") 324 | = simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| 325 | .form-inputs 326 | = f.input :email, label: false, required: false, autofocus: true, placeholder: t(".your_email") 327 | = f.input :password, label: false, required: false, placeholder: t(".your_password") 328 | = f.input :remember_me, label: false, inline_label: t(".remember_me"), as: :boolean if devise_mapping.rememberable? 329 | .form-actions 330 | = f.button :submit, t(".sign_in"), class: 'btn-block' 331 | .text-right 332 | %br 333 | = render "devise/shared/links" 334 | ``` 335 | 336 | Take into account that in order for the above code to work, you must to include your `non-controller.sass` file to the assets precompile declaration inside the **assets** initializer, you can also use the **precompiled_stylesheet** Sassish generator. 337 | 338 | ```sh 339 | $ rails g precompiled_stylesheet non-controller 340 | ``` 341 | 342 | It will add a line to include the `non-controller` style file to the assets precompile declaration (in `config/initializers/assets.rb`), but it will use the folder defined for the Sassish styles. 343 | 344 | ```sh 345 | # config/initializers/assets.rb 346 | # Precompile additional assets. 347 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. 348 | Rails.application.config.assets.precompile += %w( main/styles/non-controller.css application-welcome.css application-session.css ) 349 | ``` 350 | 351 | You can configure the Sassish folder by using an initializer, this template already includes this 352 | 353 | ```ruby 354 | Sassish.setup do |config| 355 | config.define_stylesheet_path 'main/styles' 356 | end 357 | ``` 358 | 359 | This piece of code tells Sassish that the ‘app/assets/stylesheets/**main/styles**’ folder will be used to store all individual CSS style that will be only required using either the specific **controller** or the `add_sassish_style` helper. 360 | 361 | Also, you do not need to be worried about your generators (assets, scaffold or similar), **Sassish** modifies the way how the stylesheet files are generated. Any new resources created by a generator will take into account the configured Sassish folder and the assets precompile declaration, so **Sassish** allows you to manage its approach with ease. 362 | 363 | This will generate and put the files and modify the assets precompile configuration as needed by Sassish automatically. 364 | ```sh 365 | $ rails g scaffold user 366 | $ rails g assets user 367 | ``` 368 | 369 | Finally, in order to make all this magic work, you need to replace your traditional `stylesheet_link_tag` and use `sassish_stylesheet_link_tag` instead, it performs exactly as the traditional helper, but it will automatically include the specific controller style resource (e.g. `users.sass`) and any other explicitly added styles using the `add_sassish_style helper`. 370 | 371 | ```haml 372 | !!! 373 | / app/views/layouts/application.html.haml 374 | %html 375 | %head 376 | %meta{:name => "viewport", :content => "width=device-width, initial-scale=1.0"} 377 | %title= content_for?(:title) ? yield(:title) : 'Rails Foo' 378 | %meta{:name => "description", :content => "#{content_for?(:description) ? yield(:description) : 'Rails Foo'}"} 379 | = sassish_stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true 380 | ``` 381 | 382 | 383 | TODO: We are planning on writing a blog post for explaining Sassish in depth, stay tuned! 384 | 385 | #### JAVASCRIPT LAND 386 | We have defined a way how to deal with our Javascript code, first of all, we have included Coffeescript in favor of writing plain Javascript (we still need investigate more about the new features on ES6 - you can find more information [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_in_Mozilla) and [here](https://github.com/lukehoban/es6features/blob/master/README.md)), However the main focus of our JS approach is not related with a metalenguage or a specific functionality itself, in fact our approach is pretty simple but it will save you a lot of time in the future. 387 | 388 | We propose that you manage your Javascript code using a master JS object which is segmented according to your application domain through small components (as a part of the master object), each component will have a `setup` method convention for invoking its functionality from whichever place in your rails views (whenever you need it, of course). 389 | 390 | This approach allows you to build a cleaner code facilitating its testing and maintainability. Then, you could integrate your own approach for segmenting the plain file itself (the file in which the master object is contained), you can also include something similar to [Gon](https://github.com/gazay/gon) gem for managing how the components are loaded, however, for now, we prefer to leave the JS loading process as it is. 391 | 392 | The below code shows the current structure for the `main.js.coffee` file. We have used **RailsFoo** (the app's name) as the master object's name, but it can be anything you like) : 393 | 394 | ```coffee 395 | # app/assets/javascripts/main.js.coffee 396 | window.RailsFoo = 397 | welcome: 398 | setup: -> 399 | @sayHello() 400 | return 401 | sayHello: -> 402 | console.log 'Hey yourself!' 403 | return 404 | ``` 405 | 406 | As you can see, there is a `welcome` component (i.e. 'namespace') which includes two functions, one of them is the `setup` initialization function which is in charge of invoke all necessary functions in the welcome application domain, this function should be invoked only in the view in which the component is needed. 407 | 408 | ```haml 409 | -# app/views/welcome/index.haml 410 | .site-wrapper 411 | .site-wrapper-inner 412 | ... rest of the code here... 413 | 414 | / invoking the js welcome component for this specific view 415 | / note that this is one line of plain javascript to invoke all the rest 416 | :javascript 417 | RailsFoo.welcome.setup() 418 | ``` 419 | 420 | Obviously, you are free to build your master JS object as you wish (with all namespaces and segmentation that you need), only keep in mind that your code must be in line with the DRY philosophy. By the way, the namespacing or segmentation that you use is not necessarily "by-controller" (as we did with Sassish), it instead means javascript functionality that you need to put in the page to add a required dynamic behaviour (e.g. you could have a "shoppingCart" namespace). 421 | 422 | #### BOOTSTRAP INTEGRATION 423 | This template is integrated with the [Bootstrap 3](http://getbootstrap.com/) framework. You can find some configuration about the integration in the sprocket manifest files and in the `app/assets/stylesheets/bootstrap_and_overrides.css.less` file. Also, we have integrated the [simple_form](https://github.com/plataformatec/simple_form) gem, and we have changed its wrappers' configuration to be the included bootstrap configuration, you can see this here: `config/initializers/simple_form_bootstrap.rb` (we left it as the default). If you wish, you can check a gem that may help you with bootstrap generators and templates for you to use [twitter-bootstrap-rails](https://github.com/seyhunak/twitter-bootstrap-rails). We did not include it, it's up to you. 424 | 425 | ### MISC (but not least important) 426 | #### ANALYTICS SCRIPTS 427 | One of the most important thing in this era is data analysis, you can get those metrics and data by using several existing tools ([Google Analytics](http://www.google.com/intl/en/analytics/), [Kissmetrics](https://kissmetrics.com/), [Piwik](http://piwik.org/), [Clicky](http://clicky.com/), [Woopra](https://www.woopra.com/), etc), however you really need to pay attention where you include your scripts, and to not forget about them. By the way, in order to better do stuff with tags, instead of just adding Google Analytics as usual, for example, give a try to [Google Tag Manager](http://www.google.com/tagmanager/), which let's you do this dynamically so that you don't need to alter your configuration in the code. 428 | 429 | For that reason, we have created a partial folder for including all the scripts you need for monitoring your app (yes, only a partial, there is nothing magical going on here), but bear in mind that in order for the analytics scripts to do their work you must include them in all existent pages in our web application. By the way, you can find this partial in `app/views/partials/_analytics_scripts.html.haml`. 430 | 431 | But even with that, we wanted to avoid including this partial in all our views (because we could forget!), even in all our layouts, for that reason, we have applied an inheritance approach for managing our layouts, we have created a **root** layout (you can see this located in `app/views/layouts/root.html.haml`). The main idea is that you use the **root** layout as a parent for all your new layouts, this way, you can include the common structures (like the analytical scripts) inside the **root** layout and reuse them in all your child layouts, you can see an example for this implementation in `app/views/layouts/application.html.haml` and `app/views/layouts/welcome.html.haml` layouts. The way you should think about "layout inheritance" is that you just reuse as much as you can, so, same as following DRY. 432 | 433 | #### RAILS PANEL ([GITHUB REPO](https://github.com/dejan/rails_panel)) 434 | **RailsPanel** is a Chrome extension for Rails development that will end your tailing of `development.log`. It hooks with you Chrome Dev Tools so that you have all information about your Rails app requests. Provides insight to db/rendering/total times, parameter list, rendered views and more. 435 | 436 | Although this gem is more useful for `Active record` than `Mongoid` it helps you with your logging metrics. 437 | #### SHOG ([GITHUB REPO](https://github.com/phallguy/shog)) 438 | 439 | Make your rails 4.0 log details more colorful, we think that readability is one of the most of important things in the development process, this is also the case for logs, we could use **RailsPanel** or the [request-log-analyzer](https://github.com/wvanbergen/request-log-analyzer) gem (even though this is more related with ´ActiveRecord´) but we could also get a cleaner look at our logs in the console by using Shog! (you can configure it using its initializer located in`config/initializers/shog.rb`). Just do `rails server` as usual to see how colorful your logs are now. 440 | 441 | #### JUST ONE HELPER PER VIEW 442 | In the past, we have had some problems with my helpers when my application began to grow, essentially, it is difficult to achieve a helper hierarchy structure with the default Rails helper approach. But we do not want to change the way helpers work in Rails, but at least, to guarantee that there is no place for ambiguities, for that reason we have included the following line `config.action_controller.include_all_helpers = false` in the `config/application.rb` file, it will avoid loading all existent helpers on each request (as Rails usually does). At the end only the helper associated with the specific controller and the `ApplicationHelper` will be loaded (Sassish-style again, but with helpers). 443 | 444 | #### SERVICE OBJECT 445 | Sometimes we wonder about what would be the best place for our domain logic, we are afraid for having fat controllers, but having fat models are not a solution either. We need to focus in what are the best practices for refactoring or building our code, and you can find excellent posts about this (I like [this one](http://blog.codeclimate.com/blog/2012/10/17/7-ways-to-decompose-fat-activerecord-models/)). However, I want to focus in the **Service Object** approach. This approach will help you avoid many problems in the future and will allow you to apply the [SRP](https://en.wikipedia.org/wiki/Single_responsibility_principle) with ease. 446 | 447 | You can also find many online resources (posts, guides, tutorials, screencasts, etc.) about this topic (like [this](https://netguru.co/blog/service-objects-in-rails-will-help) and [this](https://blog.engineyard.com/2014/keeping-your-rails-controllers-dry-with-services)), but I like much this [post](http://adamniedzielski.github.io/blog/2014/11/25/my-take-on-services-in-rails/) as it exposes a pretty simple way for adopting the service object philosophy. I would like to emphasize the following aspects from it: 448 | 449 | - Naming: the service object name is a **non-finite verb phrase** (wth?-> [see here](https://en.wikipedia.org/wiki/Verb_phrase)), because it denotes an action which is associated with a single responsability. Semantically it is easier to handle regarding its invocation and portability. 450 | - Invoking: use a public method named **call**, “Lambdas and Procs also respond to `call` so in your tests you have the possibility to mock the service with a simple `Lambda`, which is quite convenient”. 451 | - Structuring & Organization: a folder named **services** at the same level of the **models** folder. You can also follow the same namespacing conventions using modules and classes as commonly used in Rails (code reloads too). 452 | - Dependency Injection: having a service with many responsibilities is a signal that you need to split it, but you can always use the **dependency injection** principle for fully isolating each service object. 453 | 454 | ## IN CLOSING 455 | We have included many useful gems and tools in order to improve both our development environment and app quality according to our needs and experience, however, you can always disable whatever thing you wish or add more things, this is our starting base and it will continue evolving. 456 | ## CONTRIBUTORS 457 | 458 | 462 | 463 | ## NOTES 464 | 465 | If you want/need to migrate this template to use `ActiveRecord` instead of `MongoID` please remember to include the following (these do not support or not apply to be used with MongoID): 466 | 467 | - lol_dba 468 | - request-log-analyzer 469 | - [rails5 ActiveRecord colored SQL log backport](https://github.com/customink/activerecord-colored_log_subscriber) 470 | - annotate_models 471 | 472 | Also for newer versions consider adding: 473 | 474 | - jazz_fingers 475 | - rack-attack 476 | 477 | This template was heaviliy inspired by looking into ALL the categories from [Awesome Ruby](http://awesome-ruby.com/) the last revision for this was on July 2015, preserve its freshness by having a look every now and then (e.g. each time you create an app?) :+1:. 478 | 479 | -------------------------------------------------------------------------------- /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/new_styles_folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codescrum/rails-template-docker-kubernetes/94f77c5fdf91c0c2f0f52c11db3dac163725ad51/app/assets/images/new_styles_folder.png -------------------------------------------------------------------------------- /app/assets/images/sassish.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codescrum/rails-template-docker-kubernetes/94f77c5fdf91c0c2f0f52c11db3dac163725ad51/app/assets/images/sassish.png -------------------------------------------------------------------------------- /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 jquery_ujs 15 | //= require twitter/bootstrap 16 | //= require turbolinks 17 | //= require_tree . 18 | -------------------------------------------------------------------------------- /app/assets/javascripts/bootstrap.js.coffee: -------------------------------------------------------------------------------- 1 | jQuery -> 2 | $("a[rel~=popover], .has-popover").popover() 3 | $("a[rel~=tooltip], .has-tooltip").tooltip() 4 | -------------------------------------------------------------------------------- /app/assets/javascripts/main.js.coffee: -------------------------------------------------------------------------------- 1 | window.RailsFoo = 2 | welcome: 3 | setup: -> 4 | @sayHello() 5 | return 6 | sayHello: -> 7 | console.log 'Hey yourself!' 8 | return 9 | -------------------------------------------------------------------------------- /app/assets/stylesheets/application-welcome.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll automatically include all the stylesheets available in this directory 3 | * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at 4 | * the top of the compiled file, but it's generally better to create a new file per style scope. 5 | *= require_self 6 | *= require ./bootstrap_and_overrides 7 | *= require_tree ./common 8 | *= require_tree ./welcome 9 | */ 10 | -------------------------------------------------------------------------------- /app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll automatically include all the stylesheets available in this directory 3 | * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at 4 | * the top of the compiled file, but it's generally better to create a new file per style scope. 5 | *= require_self 6 | *= require ./bootstrap_and_overrides 7 | *= require_tree ./common 8 | *= require ./main/index 9 | */ 10 | -------------------------------------------------------------------------------- /app/assets/stylesheets/bootstrap_and_overrides.css.less: -------------------------------------------------------------------------------- 1 | @import "twitter/bootstrap/bootstrap"; 2 | 3 | // Set correct font paths 4 | @glyphiconsEotPath: font-url("glyphicons-halflings-regular.eot"); 5 | @glyphiconsEotPath_iefix: font-url("glyphicons-halflings-regular.eot?#iefix"); 6 | @glyphiconsWoffPath: font-url("glyphicons-halflings-regular.woff"); 7 | @glyphiconsTtfPath: font-url("glyphicons-halflings-regular.ttf"); 8 | @glyphiconsSvgPath: font-url("glyphicons-halflings-regular.svg#glyphicons_halflingsregular"); 9 | 10 | // Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines) 11 | @fontAwesomeEotPath: font-url("fontawesome-webfont.eot"); 12 | @fontAwesomeEotPath_iefix: font-url("fontawesome-webfont.eot?#iefix"); 13 | @fontAwesomeWoffPath: font-url("fontawesome-webfont.woff"); 14 | @fontAwesomeTtfPath: font-url("fontawesome-webfont.ttf"); 15 | @fontAwesomeSvgPath: font-url("fontawesome-webfont.svg#fontawesomeregular"); 16 | 17 | // Font Awesome 18 | @import "fontawesome/font-awesome"; 19 | 20 | // Glyphicons 21 | //@import "twitter/bootstrap/glyphicons.less"; 22 | 23 | // Your custom LESS stylesheets goes here 24 | // 25 | // Since bootstrap was imported above you have access to its mixins which 26 | // you may use and inherit here 27 | // 28 | // If you'd like to override bootstrap's own variables, you can do so here as well 29 | // See http://twitter.github.com/bootstrap/customize.html#variables for their names and documentation 30 | // 31 | // Example: 32 | // @link-color: #ff0000; 33 | -------------------------------------------------------------------------------- /app/assets/stylesheets/common/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codescrum/rails-template-docker-kubernetes/94f77c5fdf91c0c2f0f52c11db3dac163725ad51/app/assets/stylesheets/common/.gitkeep -------------------------------------------------------------------------------- /app/assets/stylesheets/main/base/_forms.sass: -------------------------------------------------------------------------------- 1 | .common_form 2 | background-color: $gray 3 | -------------------------------------------------------------------------------- /app/assets/stylesheets/main/base/_globals.sass: -------------------------------------------------------------------------------- 1 | body 2 | background-color: $blue 3 | main 4 | margin-top: 51px 5 | -------------------------------------------------------------------------------- /app/assets/stylesheets/main/base/_icons.sass: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codescrum/rails-template-docker-kubernetes/94f77c5fdf91c0c2f0f52c11db3dac163725ad51/app/assets/stylesheets/main/base/_icons.sass -------------------------------------------------------------------------------- /app/assets/stylesheets/main/base/_typography.sass: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codescrum/rails-template-docker-kubernetes/94f77c5fdf91c0c2f0f52c11db3dac163725ad51/app/assets/stylesheets/main/base/_typography.sass -------------------------------------------------------------------------------- /app/assets/stylesheets/main/base/_utils.sass: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/assets/stylesheets/main/core/_colors.sass: -------------------------------------------------------------------------------- 1 | $yellow: #FDFF9A 2 | $blue: #A4B7FF 3 | $gray: #999 4 | -------------------------------------------------------------------------------- /app/assets/stylesheets/main/core/_mixins.sass: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codescrum/rails-template-docker-kubernetes/94f77c5fdf91c0c2f0f52c11db3dac163725ad51/app/assets/stylesheets/main/core/_mixins.sass -------------------------------------------------------------------------------- /app/assets/stylesheets/main/core/_variables.sass: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codescrum/rails-template-docker-kubernetes/94f77c5fdf91c0c2f0f52c11db3dac163725ad51/app/assets/stylesheets/main/core/_variables.sass -------------------------------------------------------------------------------- /app/assets/stylesheets/main/index.sass: -------------------------------------------------------------------------------- 1 | // Setup for main section 2 | 3 | // Imports all elements that can be reused and do not render a css file 4 | @import "core/*" 5 | // Imports all segemented css elements that will be rendered in a single css file, 6 | // all of those elements represent a base rule group for the whole main section, 7 | @import "base/*" 8 | -------------------------------------------------------------------------------- /app/assets/stylesheets/main/styles/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codescrum/rails-template-docker-kubernetes/94f77c5fdf91c0c2f0f52c11db3dac163725ad51/app/assets/stylesheets/main/styles/.keep -------------------------------------------------------------------------------- /app/assets/stylesheets/welcome/cover.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Globals 3 | */ 4 | 5 | /* Links */ 6 | a, 7 | a:focus, 8 | a:hover { 9 | color: #fff; 10 | } 11 | 12 | /* Custom default button */ 13 | .btn-default, 14 | .btn-default:hover, 15 | .btn-default:focus { 16 | color: #333; 17 | text-shadow: none; /* Prevent inheritence from `body` */ 18 | background-color: #fff; 19 | border: 1px solid #fff; 20 | } 21 | 22 | 23 | /* 24 | * Base structure 25 | */ 26 | 27 | html, 28 | body { 29 | height: 100%; 30 | background-color: #333; 31 | } 32 | body { 33 | color: #fff; 34 | text-align: center; 35 | /*text-shadow: 0 1px 3px rgba(0,0,0,.5);*/ 36 | } 37 | 38 | /* Extra markup and styles for table-esque vertical and horizontal centering */ 39 | .site-wrapper { 40 | display: table; 41 | width: 100%; 42 | height: 100%; /* For at least Firefox */ 43 | min-height: 100%; 44 | -webkit-box-shadow: inset 0 0 100px rgba(0,0,0,.5); 45 | box-shadow: inset 0 0 100px rgba(0,0,0,.5); 46 | } 47 | .site-wrapper-inner { 48 | display: table-cell; 49 | vertical-align: top; 50 | } 51 | .cover-container { 52 | margin-right: auto; 53 | margin-left: auto; 54 | } 55 | 56 | /* Padding for spacing */ 57 | .inner { 58 | padding: 30px; 59 | } 60 | 61 | 62 | /* 63 | * Header 64 | */ 65 | .masthead-brand { 66 | margin-top: 10px; 67 | margin-bottom: 10px; 68 | } 69 | 70 | .masthead-nav > li { 71 | display: inline-block; 72 | } 73 | .masthead-nav > li + li { 74 | margin-left: 20px; 75 | } 76 | .masthead-nav > li > a { 77 | padding-right: 0; 78 | padding-left: 0; 79 | font-size: 16px; 80 | font-weight: bold; 81 | color: #fff; /* IE8 proofing */ 82 | color: rgba(255,255,255,.75); 83 | border-bottom: 2px solid transparent; 84 | } 85 | .masthead-nav > li > a:hover, 86 | .masthead-nav > li > a:focus { 87 | background-color: transparent; 88 | border-bottom-color: #a9a9a9; 89 | border-bottom-color: rgba(255,255,255,.25); 90 | } 91 | .masthead-nav > .active > a, 92 | .masthead-nav > .active > a:hover, 93 | .masthead-nav > .active > a:focus { 94 | color: #fff; 95 | border-bottom-color: #fff; 96 | } 97 | 98 | @media (min-width: 768px) { 99 | .masthead-brand { 100 | float: left; 101 | } 102 | .masthead-nav { 103 | float: right; 104 | } 105 | } 106 | 107 | 108 | /* 109 | * Cover 110 | */ 111 | 112 | .cover { 113 | padding: 0 20px; 114 | } 115 | .cover .btn-lg { 116 | padding: 10px 20px; 117 | font-weight: bold; 118 | } 119 | 120 | 121 | /* 122 | * Footer 123 | */ 124 | 125 | .mastfoot { 126 | color: #999; /* IE8 proofing */ 127 | color: rgba(255,255,255,.5); 128 | } 129 | 130 | 131 | /* 132 | * Affix and center 133 | */ 134 | 135 | @media (min-width: 768px) { 136 | /* Pull out the header and footer */ 137 | .masthead { 138 | position: fixed; 139 | top: 0; 140 | } 141 | .mastfoot { 142 | position: fixed; 143 | bottom: 0; 144 | } 145 | /* Start the vertical centering */ 146 | .site-wrapper-inner { 147 | vertical-align: middle; 148 | } 149 | /* Handle the widths */ 150 | .masthead, 151 | .mastfoot, 152 | .cover-container { 153 | width: 100%; /* Must be percentage or pixels for horizontal alignment */ 154 | } 155 | } 156 | 157 | @media (min-width: 992px) { 158 | .masthead, 159 | .mastfoot, 160 | .cover-container { 161 | width: 700px; 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /app/assets/stylesheets/welcome/test.sass: -------------------------------------------------------------------------------- 1 | body 2 | a.test-auto-prefixer 3 | border: solid 1px 4 | // just for testing the auto-prefixer gem 5 | text-emphasis: filled blue 6 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | # Base controller for all apps controllers 2 | class ApplicationController < ActionController::Base 3 | # Prevent CSRF attacks by raising an exception. 4 | # For APIs, you may want to use :null_session instead. 5 | protect_from_forgery with: :exception 6 | before_filter :run_my_worker 7 | 8 | # sets security-related headers automatically based on the configuration located on security_headers initializer 9 | # skip_before_filter :set_csp_header, :only => :tinymce_page 10 | ensure_security_headers 11 | 12 | def run_my_worker 13 | MyWorker.perform_async 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codescrum/rails-template-docker-kubernetes/94f77c5fdf91c0c2f0f52c11db3dac163725ad51/app/controllers/concerns/.keep -------------------------------------------------------------------------------- /app/controllers/dashboard_controller.rb: -------------------------------------------------------------------------------- 1 | # Controller associated with dashborad space, remember that this has its own 2 | # layout 3 | class DashboardController < ApplicationController 4 | # Main page for dashboard 5 | def index 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /app/controllers/welcome_controller.rb: -------------------------------------------------------------------------------- 1 | # Controller for testing purpose 2 | class WelcomeController < ApplicationController 3 | # Index page for the app 4 | def index 5 | end 6 | 7 | # Ping action for testing purpose, also it could be used in new relic monitoring 8 | def ping 9 | respond_to do |format| 10 | format.html { render text: 'pong!' } 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | # Common helper, remember that we have avoid that each controller loads all existent helpers 2 | # this could be a problem when you try to segment your helper methods, however the app 3 | # always loads both ApplicationHelper and Helper 4 | module ApplicationHelper 5 | # 6 | # Devise anywhere session stuff 7 | # 8 | def resource_name 9 | :user 10 | end 11 | 12 | # 13 | # expose devise resource for using in another controller 14 | # 15 | def resource 16 | @resource ||= User.new 17 | end 18 | 19 | # 20 | # trick for expose devise resource 21 | # 22 | def devise_mapping 23 | @devise_mapping ||= Devise.mappings[:user] 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /app/mailers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codescrum/rails-template-docker-kubernetes/94f77c5fdf91c0c2f0f52c11db3dac163725ad51/app/mailers/.keep -------------------------------------------------------------------------------- /app/models/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codescrum/rails-template-docker-kubernetes/94f77c5fdf91c0c2f0f52c11db3dac163725ad51/app/models/.keep -------------------------------------------------------------------------------- /app/models/ability.rb: -------------------------------------------------------------------------------- 1 | # Class used for describing all behaviour associated with the user abilities 2 | class Ability 3 | include CanCan::Ability 4 | 5 | # 6 | # Use this for configuring your abilities 7 | # 8 | # @param [User] user 9 | # 10 | def initialize(user) 11 | # Define abilities for the passed in user here. For example: 12 | # 13 | # user ||= User.new # guest user (not logged in) 14 | # if user.admin? 15 | # can :manage, :all 16 | # else 17 | # can :read, :all 18 | # end 19 | # 20 | # The first argument to `can` is the action you are giving the user 21 | # permission to do. 22 | # If you pass :manage it will apply to every action. Other common actions 23 | # here are :read, :create, :update and :destroy. 24 | # 25 | # The second argument is the resource the user can perform the action on. 26 | # If you pass :all it will apply to every resource. Otherwise pass a Ruby 27 | # class of the resource. 28 | # 29 | # The third argument is an optional hash of conditions to further filter the 30 | # objects. 31 | # For example, here the user can only update published articles. 32 | # 33 | # can :update, Article, :published => true 34 | # 35 | # See the wiki for details: 36 | # https://github.com/CanCanCommunity/cancancan/wiki/Defining-Abilities 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codescrum/rails-template-docker-kubernetes/94f77c5fdf91c0c2f0f52c11db3dac163725ad51/app/models/concerns/.keep -------------------------------------------------------------------------------- /app/models/user.rb: -------------------------------------------------------------------------------- 1 | # User model wrapped by the devise gem 2 | class User 3 | include Mongoid::Document 4 | # Include default devise modules. Others available are: 5 | # :confirmable, :lockable, :timeoutable and :omniauthable 6 | devise :database_authenticatable, :registerable, 7 | :recoverable, :rememberable, :trackable, :validatable 8 | 9 | ## Database authenticatable 10 | field :email, type: String, default: '' 11 | field :encrypted_password, type: String, default: '' 12 | 13 | ## Recoverable 14 | field :reset_password_token, type: String 15 | field :reset_password_sent_at, type: Time 16 | 17 | ## Rememberable 18 | field :remember_created_at, type: Time 19 | 20 | ## Trackable 21 | field :sign_in_count, type: Integer, default: 0 22 | field :current_sign_in_at, type: Time 23 | field :last_sign_in_at, type: Time 24 | field :current_sign_in_ip, type: String 25 | field :last_sign_in_ip, type: String 26 | 27 | ## Confirmable 28 | # field :confirmation_token, type: String 29 | # field :confirmed_at, type: Time 30 | # field :confirmation_sent_at, type: Time 31 | # field :unconfirmed_email, type: String # Only if using reconfirmable 32 | 33 | ## Lockable 34 | # field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts 35 | # field :unlock_token, type: String # Only if unlock strategy is :email or :both 36 | # field :locked_at, type: Time 37 | 38 | # 39 | # Fix error for devise and mongoid integration, error happens because the warden session is not right 40 | # 41 | # @param [Mongoid::Document] record 42 | # 43 | # @return [Array] 44 | # 45 | def self.serialize_into_session(record) 46 | [record.id.to_s, record.authenticatable_salt] 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /app/views/devise/confirmations/new.html.haml: -------------------------------------------------------------------------------- 1 | %h2 Resend confirmation instructions 2 | = simple_form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| 3 | = f.error_notification 4 | = f.full_error :confirmation_token 5 | .form-inputs 6 | = f.input :email, required: true, autofocus: true 7 | .form-actions 8 | = f.button :submit, "Resend confirmation instructions" 9 | = render "devise/shared/links" 10 | -------------------------------------------------------------------------------- /app/views/devise/mailer/confirmation_instructions.html.haml: -------------------------------------------------------------------------------- 1 | %p 2 | Welcome #{@email}! 3 | %p You can confirm your account email through the link below: 4 | %p= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) 5 | -------------------------------------------------------------------------------- /app/views/devise/mailer/reset_password_instructions.html.haml: -------------------------------------------------------------------------------- 1 | %p 2 | Hello #{@resource.email}! 3 | %p Someone has requested a link to change your password. You can do this through the link below. 4 | %p= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) 5 | %p If you didn't request this, please ignore this email. 6 | %p Your password won't change until you access the link above and create a new one. 7 | -------------------------------------------------------------------------------- /app/views/devise/mailer/unlock_instructions.html.haml: -------------------------------------------------------------------------------- 1 | %p 2 | Hello #{@resource.email}! 3 | %p Your account has been locked due to an excessive number of unsuccessful sign in attempts. 4 | %p Click the link below to unlock your account: 5 | %p= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) 6 | -------------------------------------------------------------------------------- /app/views/devise/passwords/edit.html.haml: -------------------------------------------------------------------------------- 1 | %h2 Change your password 2 | = simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| 3 | = f.error_notification 4 | = f.input :reset_password_token, as: :hidden 5 | = f.full_error :reset_password_token 6 | .form-inputs 7 | = f.input :password, label: "New password", required: true, autofocus: true 8 | = f.input :password_confirmation, label: "Confirm your new password", required: true 9 | .form-actions 10 | = f.button :submit, "Change my password" 11 | = render "devise/shared/links" 12 | -------------------------------------------------------------------------------- /app/views/devise/passwords/new.html.haml: -------------------------------------------------------------------------------- 1 | %h2 Forgot your password? 2 | = simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| 3 | = f.error_notification 4 | .form-inputs 5 | = f.input :email, required: true, autofocus: true 6 | .form-actions 7 | = f.button :submit, "Send me reset password instructions" 8 | = render "devise/shared/links" 9 | -------------------------------------------------------------------------------- /app/views/devise/registrations/edit.html.haml: -------------------------------------------------------------------------------- 1 | .row 2 | .col-sm-4.col-sm-offset-4 3 | %h2 4 | Edit #{resource_name.to_s.humanize} 5 | = simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| 6 | = f.error_notification 7 | .form-inputs 8 | = f.input :email, required: true, autofocus: true 9 | - if devise_mapping.confirmable? && resource.pending_reconfirmation? 10 | %p 11 | Currently waiting confirmation for: #{resource.unconfirmed_email} 12 | = f.input :password, autocomplete: "off", hint: "leave it blank if you don't want to change it", required: false 13 | = f.input :password_confirmation, required: false 14 | = f.input :current_password, hint: "we need your current password to confirm your changes", required: true 15 | .form-actions 16 | = f.button :submit, "Update" 17 | %h3 Cancel my account 18 | %p 19 | Unhappy? #{link_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete} 20 | = link_to "Back", :back 21 | -------------------------------------------------------------------------------- /app/views/devise/registrations/new.html.haml: -------------------------------------------------------------------------------- 1 | .row 2 | .col-sm-4.col-sm-offset-4 3 | %h2 Sign up 4 | = simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| 5 | = f.error_notification 6 | .form-inputs 7 | = f.input :email, required: true, autofocus: true 8 | = f.input :password, required: true 9 | = f.input :password_confirmation, required: true 10 | .form-actions 11 | = f.button :submit, "Sign up" 12 | = render "devise/shared/links" 13 | -------------------------------------------------------------------------------- /app/views/devise/sessions/_sign_in_form.html.haml: -------------------------------------------------------------------------------- 1 | / - add_sassish_style 'main/styles/another_style' 2 | %h2= t(".sign_in") 3 | = simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| 4 | .form-inputs 5 | = f.input :email, label: false, required: false, autofocus: true, placeholder: t(".your_email") 6 | = f.input :password, label: false, required: false, placeholder: t(".your_password") 7 | = f.input :remember_me, label: false, inline_label: t(".remember_me"), as: :boolean if devise_mapping.rememberable? 8 | .form-actions 9 | = f.button :submit, t(".sign_in"), class: 'btn-block' 10 | .text-right 11 | %br 12 | = render "devise/shared/links" 13 | -------------------------------------------------------------------------------- /app/views/devise/sessions/new.html.haml: -------------------------------------------------------------------------------- 1 | .row 2 | .col-sm-4.col-sm-offset-4 3 | = render 'sign_in_form' 4 | -------------------------------------------------------------------------------- /app/views/devise/shared/_links.haml: -------------------------------------------------------------------------------- 1 | - if controller_name != 'sessions' 2 | = link_to t(".log_in"), new_session_path(resource_name) 3 | %br/ 4 | - if devise_mapping.registerable? && controller_name != 'registrations' 5 | = link_to t(".sign_up"), new_registration_path(resource_name) 6 | %br/ 7 | - if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' 8 | = link_to t(".forgot_your_password"), new_password_path(resource_name) 9 | %br/ 10 | - if devise_mapping.confirmable? && controller_name != 'confirmations' 11 | = link_to t(".didnt_receive_confirmation_in"), new_confirmation_path(resource_name) 12 | %br/ 13 | - if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' 14 | = link_to t(".didn't_receive_unlock_instruct"), new_unlock_path(resource_name) 15 | %br/ 16 | - if devise_mapping.omniauthable? 17 | - resource_class.omniauth_providers.each do |provider| 18 | = link_to = t(".sign_in_with_provider", provider: provider.to_s.titleize), omniauth_authorize_path(resource_name, provider) 19 | %br/ 20 | -------------------------------------------------------------------------------- /app/views/devise/unlocks/new.html.haml: -------------------------------------------------------------------------------- 1 | %h2 Resend unlock instructions 2 | = simple_form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| 3 | = f.error_notification 4 | = f.full_error :unlock_token 5 | .form-inputs 6 | = f.input :email, required: true, autofocus: true 7 | .form-actions 8 | = f.button :submit, "Resend unlock instructions" 9 | = render "devise/shared/links" 10 | -------------------------------------------------------------------------------- /app/views/layouts/_messages.html.haml: -------------------------------------------------------------------------------- 1 | -# Rails flash messages styled for Bootstrap 3.0 2 | - flash.each do |name, msg| 3 | - if msg.is_a?(String) 4 | %div{:class => "alert alert-#{name.to_s == 'notice' ? 'success' : 'danger'}"} 5 | %button.close{"aria-hidden" => "true", "data-dismiss" => "alert", :type => "button"} × 6 | = content_tag :div, msg, :id => "flash_#{name}" 7 | -------------------------------------------------------------------------------- /app/views/layouts/_navigation.html.haml: -------------------------------------------------------------------------------- 1 | -# navigation styled for Bootstrap 3.0 2 | %nav.navbar.navbar-default.navbar-fixed-top 3 | .container 4 | .navbar-header 5 | %button.navbar-toggle{"data-target" => ".navbar-collapse", "data-toggle" => "collapse", :type => "button"} 6 | %span.sr-only Toggle navigation 7 | %span.icon-bar 8 | %span.icon-bar 9 | %span.icon-bar 10 | = link_to 'Home', root_path, class: 'navbar-brand' 11 | .collapse.navbar-collapse 12 | %ul.nav.navbar-nav 13 | = render 'layouts/navigation_links' 14 | -------------------------------------------------------------------------------- /app/views/layouts/_navigation_links.html.erb: -------------------------------------------------------------------------------- 1 | <%# add navigation links to this file %> 2 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.haml: -------------------------------------------------------------------------------- 1 | - content_for :head_content do 2 | %meta{:name => "viewport", :content => "width=device-width, initial-scale=1.0"} 3 | %title= content_for?(:title) ? yield(:title) : 'Rails Foo' 4 | %meta{:name => "description", :content => "#{content_for?(:description) ? yield(:description) : 'Rails Foo'}"} 5 | = sassish_stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true 6 | = javascript_include_tag 'application', 'data-turbolinks-track' => true 7 | = csrf_meta_tags 8 | 9 | - content_for :body_content do 10 | %header 11 | = render 'layouts/navigation' 12 | %main{:role => "main"} 13 | = render 'layouts/messages' 14 | = yield 15 | 16 | = render template: 'layouts/root' 17 | -------------------------------------------------------------------------------- /app/views/layouts/root.html.haml: -------------------------------------------------------------------------------- 1 | !!! 2 | %html 3 | %head 4 | = yield :head_content 5 | %body 6 | = yield :body_content 7 | = render 'partials/analytics_scripts' 8 | -------------------------------------------------------------------------------- /app/views/layouts/welcome.html.haml: -------------------------------------------------------------------------------- 1 | - content_for :head_content do 2 | %meta{:name => "viewport", :content => "width=device-width, initial-scale=1.0"} 3 | %title= content_for?(:title) ? yield(:title) : 'Rails Foo' 4 | %meta{:name => "description", :content => "#{content_for?(:description) ? yield(:description) : 'Rails Foo'}"} 5 | = stylesheet_link_tag 'application-welcome', media: 'all', 'data-turbolinks-track' => true 6 | = javascript_include_tag 'application', 'data-turbolinks-track' => true 7 | = csrf_meta_tags 8 | 9 | - content_for :body_content do 10 | = yield 11 | 12 | = render template: 'layouts/root' 13 | -------------------------------------------------------------------------------- /app/views/partials/_analytics_scripts.html.haml: -------------------------------------------------------------------------------- 1 | - if Rails.env.production? 2 | :javascript 3 | // Your analytics scripts here 4 | -------------------------------------------------------------------------------- /app/views/welcome/index.html.haml: -------------------------------------------------------------------------------- 1 | - content_for :title, 'Welcome Page' 2 | .site-wrapper 3 | .site-wrapper-inner 4 | .cover-container 5 | .masthead.clearfix 6 | .inner 7 | %h3.masthead-brand= t(".generic") 8 | %ul.nav.masthead-nav 9 | %li.active 10 | %a{:href => "#"}= t(".home") 11 | %li 12 | %a{:href => "#"}= t(".about_us") 13 | %li 14 | %a{:href => "#"}= t(".contact") 15 | .inner.cover 16 | %h1.cover-heading= t(".demo_application") 17 | %p.lead= t(".demo_app_description") 18 | %p.lead 19 | %a.btn.btn-lg.btn-primary{:href => new_user_session_path}= t(".sign_in") 20 | .mastfoot 21 | .inner 22 | %p 23 | = t(".all_rights_reserved") 24 | = succeed "," do 25 | %a.test-auto-prefixer{:href => "#"}= t(".generic") 26 | 27 | :javascript 28 | RailsFoo.welcome.setup() 29 | -------------------------------------------------------------------------------- /app/workers/my_worker.rb: -------------------------------------------------------------------------------- 1 | class MyWorker 2 | include Sidekiq::Worker 3 | 4 | def perform 5 | p "This is the current time: #{DateTime.now}" 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /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 | APP_PATH = File.expand_path('../../config/application', __FILE__) 3 | require_relative '../config/boot' 4 | require 'rails/commands' 5 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative '../config/boot' 3 | require 'rake' 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /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 | # Pick the frameworks you want: 4 | require "active_model/railtie" 5 | # require "active_record/railtie" 6 | require "action_controller/railtie" 7 | require "action_mailer/railtie" 8 | require "action_view/railtie" 9 | require "sprockets/railtie" 10 | # require "rails/test_unit/railtie" 11 | 12 | # Require the gems listed in Gemfile, including any gems 13 | # you've limited to :test, :development, or :production. 14 | Bundler.require(*Rails.groups) 15 | 16 | module RailsTemplate 17 | class Application < Rails::Application 18 | # Settings in config/environments/* take precedence over those specified here. 19 | # Application configuration should go into files in config/initializers 20 | # -- all .rb files in that directory are automatically loaded. 21 | 22 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 23 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 24 | # config.time_zone = 'Central Time (US & Canada)' 25 | 26 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 27 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 28 | # config.i18n.default_locale = :de 29 | 30 | # Auto-loading lib files 31 | config.autoload_paths << Rails.root.join('lib/sassish') 32 | 33 | # Avoids that each controller loads all existent helpers, this could be a problem 34 | # when you try to segment your helper methods 35 | config.action_controller.include_all_helpers = false 36 | end 37 | end 38 | 39 | # Require Sassish 40 | require File.expand_path(File.join('..', '..', 'lib', 'sassish', 'sassish.rb'), __FILE__) 41 | 42 | ###### Heroku/Docker deployment hack ###### 43 | # copy mongoid config example file into 'real' file 44 | if Rails.env.production? || Rails.env.staging? 45 | config_root = File.join(Rails.root, 'config') 46 | # Mongoid Config File 47 | mongoid_example_path = File.join(config_root, 'mongoid.yml.example') 48 | mongoid_real_path = File.join(config_root, 'mongoid.yml') 49 | `cp #{mongoid_example_path} #{mongoid_real_path}` 50 | # Secrets File 51 | secrets_example_path = File.join(config_root, 'secrets.yml.example') 52 | secrets_real_path = File.join(config_root, 'secrets.yml') 53 | `cp #{secrets_example_path} #{secrets_real_path}` 54 | end 55 | -------------------------------------------------------------------------------- /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/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Do not eager load code on boot. 10 | config.eager_load = false 11 | 12 | # Show full error reports and disable caching. 13 | config.consider_all_requests_local = true 14 | config.action_controller.perform_caching = false 15 | 16 | # Don't care if the mailer can't send. 17 | config.action_mailer.raise_delivery_errors = false 18 | 19 | # Print deprecation notices to the Rails logger. 20 | config.active_support.deprecation = :log 21 | 22 | # Debug mode disables concatenation and preprocessing of assets. 23 | # This option may cause significant delays in view rendering with a large 24 | # number of complex assets. 25 | config.assets.debug = true 26 | 27 | # Adds additional error checking when serving assets at runtime. 28 | # Checks for improperly declared sprockets dependencies. 29 | # Raises helpful error messages. 30 | config.assets.raise_runtime_errors = true 31 | 32 | # Raises error for missing translations 33 | # config.action_view.raise_on_missing_translations = true 34 | 35 | config.sass.preferred_syntax = :sass 36 | 37 | # Caches all the dynamic stylesheet resources for avoiding that 38 | # the existing stylesheet verification hits the hard disk, this 39 | # action is really useful in production environments for improving 40 | # the performance when the sassish module is included. 41 | config.sassish.cache_stylesheet_resources = false 42 | 43 | # Bullet configuration 44 | config.after_initialize do 45 | Bullet.enable = true 46 | Bullet.rails_logger = true 47 | #Bullet.alert = true 48 | #Bullet.bullet_logger = true 49 | end 50 | end 51 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # Code is not reloaded between requests. 5 | config.cache_classes = true 6 | 7 | # Eager load code on boot. This eager loads most of Rails and 8 | # your application in memory, allowing both threaded web servers 9 | # and those relying on copy on write to perform better. 10 | # Rake tasks automatically ignore this option for performance. 11 | config.eager_load = true 12 | 13 | # Full error reports are disabled and caching is turned on. 14 | config.consider_all_requests_local = false 15 | config.action_controller.perform_caching = true 16 | 17 | # Enable Rack::Cache to put a simple HTTP cache in front of your application 18 | # Add `rack-cache` to your Gemfile before enabling this. 19 | # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. 20 | # config.action_dispatch.rack_cache = true 21 | 22 | # Disable Rails's static asset server (Apache or nginx will already do this). 23 | config.serve_static_files = false 24 | 25 | # Compress JavaScripts and CSS. 26 | config.assets.js_compressor = :uglifier 27 | # config.assets.css_compressor = :sass 28 | 29 | # Do not fallback to assets pipeline if a precompiled asset is missed. 30 | config.assets.compile = true 31 | 32 | # Generate digests for assets URLs. 33 | config.assets.digest = true 34 | 35 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb 36 | 37 | # Specifies the header that your server uses for sending files. 38 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache 39 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx 40 | 41 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 42 | # config.force_ssl = true 43 | 44 | # Set to :debug to see everything in the log. 45 | config.log_level = :info 46 | 47 | # Prepend all log lines with the following tags. 48 | # config.log_tags = [ :subdomain, :uuid ] 49 | 50 | # Use a different logger for distributed setups. 51 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) 52 | 53 | # Use a different cache store in production. 54 | # config.cache_store = :mem_cache_store 55 | 56 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 57 | # config.action_controller.asset_host = "http://assets.example.com" 58 | 59 | # Ignore bad email addresses and do not raise email delivery errors. 60 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 61 | # config.action_mailer.raise_delivery_errors = false 62 | 63 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 64 | # the I18n.default_locale when a translation cannot be found). 65 | config.i18n.fallbacks = true 66 | 67 | # Send deprecation notices to registered listeners. 68 | config.active_support.deprecation = :notify 69 | 70 | # Disable automatic flushing of the log to improve performance. 71 | # config.autoflush_log = false 72 | 73 | # Use default logging formatter so that PID and timestamp are not suppressed. 74 | config.log_formatter = ::Logger::Formatter.new 75 | 76 | # Caches all the dynamic stylesheet resources for avoiding that 77 | # the existing stylesheet verification hits the hard disk, this 78 | # action is really useful in production environments for improving 79 | # the performance when the sassish module is included 80 | config.sassish.cache_stylesheet_resources = true 81 | end 82 | -------------------------------------------------------------------------------- /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 | config.sass.preferred_syntax = :sass 30 | 31 | # Tell Action Mailer not to deliver emails to the real world. 32 | # The :test delivery method accumulates sent emails in the 33 | # ActionMailer::Base.deliveries array. 34 | config.action_mailer.delivery_method = :test 35 | 36 | # Print deprecation notices to the stderr. 37 | config.active_support.deprecation = :stderr 38 | 39 | # Raises error for missing translations 40 | # config.action_view.raise_on_missing_translations = true 41 | end 42 | -------------------------------------------------------------------------------- /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( application-welcome.css application-session.css ) 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 = Rails.application.secrets.secret_key_base 8 | config.secret_key = '223ef05656d06eca87dc9f635ca96020df3d50ea83a387626f7f70f3bb332694568839e676c5b16a29b7ca123f9ba3133396c4f57be66a67973915b9c49e7b8c' 9 | 10 | # ==> Mailer Configuration 11 | # Configure the e-mail address which will be shown in Devise::Mailer, 12 | # note that it will be overwritten if you use your own mailer class 13 | # with default "from" parameter. 14 | config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com' 15 | 16 | # Configure the class responsible to send e-mails. 17 | # config.mailer = 'Devise::Mailer' 18 | 19 | # ==> ORM configuration 20 | # Load and configure the ORM. Supports :active_record (default) and 21 | # :mongoid (bson_ext recommended) by default. Other ORMs may be 22 | # available as additional gems. 23 | require 'devise/orm/mongoid' 24 | 25 | # ==> Configuration for any authentication mechanism 26 | # Configure which keys are used when authenticating a user. The default is 27 | # just :email. You can configure it to use [:username, :subdomain], so for 28 | # authenticating a user, both parameters are required. Remember that those 29 | # parameters are used only when authenticating and not when retrieving from 30 | # session. If you need permissions, you should implement that in a before filter. 31 | # You can also supply a hash where the value is a boolean determining whether 32 | # or not authentication should be aborted when the value is not present. 33 | # config.authentication_keys = [ :email ] 34 | 35 | # Configure parameters from the request object used for authentication. Each entry 36 | # given should be a request method and it will automatically be passed to the 37 | # find_for_authentication method and considered in your model lookup. For instance, 38 | # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. 39 | # The same considerations mentioned for authentication_keys also apply to request_keys. 40 | # config.request_keys = [] 41 | 42 | # Configure which authentication keys should be case-insensitive. 43 | # These keys will be downcased upon creating or modifying a user and when used 44 | # to authenticate or find a user. Default is :email. 45 | config.case_insensitive_keys = [ :email ] 46 | 47 | # Configure which authentication keys should have whitespace stripped. 48 | # These keys will have whitespace before and after removed upon creating or 49 | # modifying a user and when used to authenticate or find a user. Default is :email. 50 | config.strip_whitespace_keys = [ :email ] 51 | 52 | # Tell if authentication through request.params is enabled. True by default. 53 | # It can be set to an array that will enable params authentication only for the 54 | # given strategies, for example, `config.params_authenticatable = [:database]` will 55 | # enable it only for database (email + password) authentication. 56 | # config.params_authenticatable = true 57 | 58 | # Tell if authentication through HTTP Auth is enabled. False by default. 59 | # It can be set to an array that will enable http authentication only for the 60 | # given strategies, for example, `config.http_authenticatable = [:database]` will 61 | # enable it only for database authentication. The supported strategies are: 62 | # :database = Support basic authentication with authentication key + password 63 | # config.http_authenticatable = false 64 | 65 | # If http headers should be returned for AJAX requests. True by default. 66 | # config.http_authenticatable_on_xhr = true 67 | 68 | # The realm used in Http Basic Authentication. 'Application' by default. 69 | # config.http_authentication_realm = 'Application' 70 | 71 | # It will change confirmation, password recovery and other workflows 72 | # to behave the same regardless if the e-mail provided was right or wrong. 73 | # Does not affect registerable. 74 | # config.paranoid = true 75 | 76 | # By default Devise will store the user in session. You can skip storage for 77 | # particular strategies by setting this option. 78 | # Notice that if you are skipping storage for all authentication paths, you 79 | # may want to disable generating routes to Devise's sessions controller by 80 | # passing skip: :sessions to `devise_for` in your config/routes.rb 81 | config.skip_session_storage = [:http_auth] 82 | 83 | # By default, Devise cleans up the CSRF token on authentication to 84 | # avoid CSRF token fixation attacks. This means that, when using AJAX 85 | # requests for sign in and sign up, you need to get a new CSRF token 86 | # from the server. You can disable this option at your own risk. 87 | # config.clean_up_csrf_token_on_authentication = true 88 | 89 | # ==> Configuration for :database_authenticatable 90 | # For bcrypt, this is the cost for hashing the password and defaults to 10. If 91 | # using other encryptors, it sets how many times you want the password re-encrypted. 92 | # 93 | # Limiting the stretches to just one in testing will increase the performance of 94 | # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use 95 | # a value less than 10 in other environments. Note that, for bcrypt (the default 96 | # encryptor), the cost increases exponentially with the number of stretches (e.g. 97 | # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation). 98 | config.stretches = Rails.env.test? ? 1 : 10 99 | 100 | # Setup a pepper to generate the encrypted password. 101 | # config.pepper = '1eb859c028ba631c1d160334ae468214fd2d74071608b2a68397351557d85a821765d9bd6af2aec3668f5ba2920863025a48d21ba514a30d3932c77fbbce5897' 102 | 103 | # ==> Configuration for :confirmable 104 | # A period that the user is allowed to access the website even without 105 | # confirming their account. For instance, if set to 2.days, the user will be 106 | # able to access the website for two days without confirming their account, 107 | # access will be blocked just in the third day. Default is 0.days, meaning 108 | # the user cannot access the website without confirming their account. 109 | # config.allow_unconfirmed_access_for = 2.days 110 | 111 | # A period that the user is allowed to confirm their account before their 112 | # token becomes invalid. For example, if set to 3.days, the user can confirm 113 | # their account within 3 days after the mail was sent, but on the fourth day 114 | # their account can't be confirmed with the token any more. 115 | # Default is nil, meaning there is no restriction on how long a user can take 116 | # before confirming their account. 117 | # config.confirm_within = 3.days 118 | 119 | # If true, requires any email changes to be confirmed (exactly the same way as 120 | # initial account confirmation) to be applied. Requires additional unconfirmed_email 121 | # db field (see migrations). Until confirmed, new email is stored in 122 | # unconfirmed_email column, and copied to email column on successful confirmation. 123 | config.reconfirmable = true 124 | 125 | # Defines which key will be used when confirming an account 126 | # config.confirmation_keys = [ :email ] 127 | 128 | # ==> Configuration for :rememberable 129 | # The time the user will be remembered without asking for credentials again. 130 | # config.remember_for = 2.weeks 131 | 132 | # Invalidates all the remember me tokens when the user signs out. 133 | config.expire_all_remember_me_on_sign_out = true 134 | 135 | # If true, extends the user's remember period when remembered via cookie. 136 | # config.extend_remember_period = false 137 | 138 | # Options to be passed to the created cookie. For instance, you can set 139 | # secure: true in order to force SSL only cookies. 140 | # config.rememberable_options = {} 141 | 142 | # ==> Configuration for :validatable 143 | # Range for password length. 144 | config.password_length = 8..128 145 | 146 | # Email regex used to validate email formats. It simply asserts that 147 | # one (and only one) @ exists in the given string. This is mainly 148 | # to give user feedback and not to assert the e-mail validity. 149 | # config.email_regexp = /\A[^@]+@[^@]+\z/ 150 | 151 | # ==> Configuration for :timeoutable 152 | # The time you want to timeout the user session without activity. After this 153 | # time the user will be asked for credentials again. Default is 30 minutes. 154 | # config.timeout_in = 30.minutes 155 | 156 | # If true, expires auth token on session timeout. 157 | # config.expire_auth_token_on_timeout = false 158 | 159 | # ==> Configuration for :lockable 160 | # Defines which strategy will be used to lock an account. 161 | # :failed_attempts = Locks an account after a number of failed attempts to sign in. 162 | # :none = No lock strategy. You should handle locking by yourself. 163 | # config.lock_strategy = :failed_attempts 164 | 165 | # Defines which key will be used when locking and unlocking an account 166 | # config.unlock_keys = [ :email ] 167 | 168 | # Defines which strategy will be used to unlock an account. 169 | # :email = Sends an unlock link to the user email 170 | # :time = Re-enables login after a certain amount of time (see :unlock_in below) 171 | # :both = Enables both strategies 172 | # :none = No unlock strategy. You should handle unlocking by yourself. 173 | # config.unlock_strategy = :both 174 | 175 | # Number of authentication tries before locking an account if lock_strategy 176 | # is failed attempts. 177 | # config.maximum_attempts = 20 178 | 179 | # Time interval to unlock the account if :time is enabled as unlock_strategy. 180 | # config.unlock_in = 1.hour 181 | 182 | # Warn on the last attempt before the account is locked. 183 | # config.last_attempt_warning = false 184 | 185 | # ==> Configuration for :recoverable 186 | # 187 | # Defines which key will be used when recovering the password for an account 188 | # config.reset_password_keys = [ :email ] 189 | 190 | # Time interval you can reset your password with a reset password key. 191 | # Don't put a too small interval or your users won't have the time to 192 | # change their passwords. 193 | config.reset_password_within = 6.hours 194 | 195 | # ==> Configuration for :encryptable 196 | # Allow you to use another encryption algorithm besides bcrypt (default). You can use 197 | # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1, 198 | # :authlogic_sha512 (then you should set stretches above to 20 for default behavior) 199 | # and :restful_authentication_sha1 (then you should set stretches to 10, and copy 200 | # REST_AUTH_SITE_KEY to pepper). 201 | # 202 | # Require the `devise-encryptable` gem when using anything other than bcrypt 203 | # config.encryptor = :sha512 204 | 205 | # ==> Scopes configuration 206 | # Turn scoped views on. Before rendering "sessions/new", it will first check for 207 | # "users/sessions/new". It's turned off by default because it's slower if you 208 | # are using only default views. 209 | # config.scoped_views = false 210 | 211 | # Configure the default scope given to Warden. By default it's the first 212 | # devise role declared in your routes (usually :user). 213 | # config.default_scope = :user 214 | 215 | # Set this configuration to false if you want /users/sign_out to sign out 216 | # only the current scope. By default, Devise signs out all scopes. 217 | # config.sign_out_all_scopes = true 218 | 219 | # ==> Navigation configuration 220 | # Lists the formats that should be treated as navigational. Formats like 221 | # :html, should redirect to the sign in page when the user does not have 222 | # access, but formats like :xml or :json, should return 401. 223 | # 224 | # If you have any extra navigational formats, like :iphone or :mobile, you 225 | # should add them to the navigational formats lists. 226 | # 227 | # The "*/*" below is required to match Internet Explorer requests. 228 | # config.navigational_formats = ['*/*', :html] 229 | 230 | # The default HTTP method used to sign out a resource. Default is :delete. 231 | config.sign_out_via = :delete 232 | 233 | # ==> OmniAuth 234 | # Add a new OmniAuth provider. Check the wiki for more information on setting 235 | # up on your models and hooks. 236 | # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo' 237 | 238 | # ==> Warden configuration 239 | # If you want to use other strategies, that are not supported by Devise, or 240 | # change the failure app, you can configure them inside the config.warden block. 241 | # 242 | # config.warden do |manager| 243 | # manager.intercept_401 = false 244 | # manager.default_strategies(scope: :user).unshift :some_external_strategy 245 | # end 246 | 247 | # ==> Mountable engine configurations 248 | # When using Devise inside an engine, let's call it `MyEngine`, and this engine 249 | # is mountable, there are some extra configurations to be taken into account. 250 | # The following options are available, assuming the engine is mounted as: 251 | # 252 | # mount MyEngine, at: '/my_engine' 253 | # 254 | # The router that invoked `devise_for`, in the example above, would be: 255 | # config.router_name = :my_engine 256 | # 257 | # When using omniauth, Devise cannot automatically set Omniauth path, 258 | # so you need to do it manually. For the users scope, it would be: 259 | # config.omniauth_path_prefix = '/my_engine/users/auth' 260 | end 261 | -------------------------------------------------------------------------------- /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/rack_profiler.rb: -------------------------------------------------------------------------------- 1 | if Rails.env == 'development' 2 | require 'rack-mini-profiler' 3 | Rack::MiniProfilerRails.initialize!(Rails.application) 4 | end 5 | -------------------------------------------------------------------------------- /config/initializers/sassish.rb: -------------------------------------------------------------------------------- 1 | Sassish.setup do |config| 2 | config.define_stylesheet_path 'main/styles' 3 | end 4 | -------------------------------------------------------------------------------- /config/initializers/security_headers.rb: -------------------------------------------------------------------------------- 1 | ::SecureHeaders::Configuration.configure do |config| 2 | 3 | # Strict Transport Security 4 | # is a security feature that lets a web site tell browsers that it should only be communicated with using HTTPS, instead of using HTTP. 5 | # - Browser compatibility: 6 | # IE: 11 7 | # Chrome: > 4 8 | # Firefox: > 4 9 | # Opera: 12 10 | # Safari: 7 11 | # see more info here: 12 | # https://goo.gl/ldjc5h 13 | config.hsts = if Rails.env.production? 14 | { 15 | # The time, in seconds, that the browser should remember that this site is only to be accessed using HTTPS. 16 | :max_age => 20.years.to_i, 17 | # If this optional parameter is specified, this rule applies to all of the site's subdomains as well. 18 | :include_subdomains => true 19 | } 20 | else 21 | false 22 | end 23 | 24 | # Prevents your content from being framed and potentially clickjacked 25 | config.x_frame_options = 'DENY' 26 | # Prevent content type sniffing 27 | # This is a security feature that helps prevent attacks based on MIME-type confusion. 28 | config.x_content_type_options = "nosniff" 29 | # Cross site scripting heuristic filter for IE/Chrome 30 | config.x_xss_protection = {:value => 1, :mode => 'block'} 31 | # Prevent file downloads opening 32 | config.x_download_options = 'noopen' 33 | # Restrict Adobe Flash Player's access to data 34 | config.x_permitted_cross_domain_policies = 'none' 35 | 36 | # Content Security Policy 37 | # is an added layer of security that helps to detect and mitigate certain types of attacks, including Cross Site Scripting (XSS) and data injection attacks. 38 | # These attacks are used for everything from data theft to site defacement or distribution of malware. 39 | # - Browser compatibility: 40 | # IE: Edge 41 | # Chrome: > 25 42 | # Firefox: > 24 43 | # Opera: 15 44 | # Safari: 7 45 | # see more info here: 46 | # https://goo.gl/u23dit 47 | # https://goo.gl/wHC9C5 48 | # https://goo.gl/Z8UvAz 49 | config.csp = { 50 | # It's often valuable to send extra information in the report uri that is not available in the reports themselves. Namely, "was the policy enforced" 51 | # and "where did the report come from" 52 | :app_name => "rails_foo", # do not use spaces here 53 | :tag_report_uri => true, 54 | :enforce => true, 55 | # The default-src directive defines the security policy for types of content which are not expressly called out by more specific directives. 56 | :default_src => "https: self inline eval", 57 | # The frame-src directive specifies valid sources for web workers and nested browsing contexts loading using elements such as and