Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Initial Commit - Chris Raethke - BrisRuby 26/09...

Initial Commit - Chris Raethke - BrisRuby 26/09/2017

It’s easy to build another DHH blog post example, but what do the first 10 commits look like when you’re building a ‘real’ application for ‘real’ business needs.

Mitchell Buckley

September 26, 2017
Tweet

Other Decks in Programming

Transcript

  1. # Gemfile
 # delete all the crap comments
 # sort

    alphabetically gem ‘bootstrap’ gem 'sass-rails' gem ‘slim-rails’
  2. # run it gem install foreman echo "web: bundle exec

    puma -C config/ puma.rb" > Procfile foreman start
  3. # lint all the things gem install rubycritic # reek,

    flay, etc. all come for free rubycritic app config lib
  4. # Gemfile
 # catch all the bugs gem ‘bugsnag’ #

    .env
 # configuration required for foreman BUGSNAG_API_KEY=13d1859356026827…etc # .gitignore .env
  5. # log all the things gem ‘le’
 gem ‘loggly’ #

    many options # reduce noise gem ‘lograge’ # config/initializers/lograge.rb # optional, level up with tagged logging
  6. # sexy error pages # 404.html
 # 503.html
 # maintenance.html

    https://better-error-pages.statuspage.io/
  7. 
 # get ready for actual functionality
 gem ‘rspec-rails’ #

    reduce load times by 30-50%
 gem ‘bootsnap’ 

  8. # git push production ftw # junit formatting - failed

    & slow tests
 # custom deployments
 # custom hotfix tasks
 # custom migration tasks circle.yml

  9. 
 # funnel in sign ups # Gemfile
 gem 'devise'


    gem ‘devise-invitable’ # model.rb
 User.invite! {email: ‘[email protected]'}, current_user 

  10. 
 # if it sensitive, encrypt it # Gemfile
 gem

    'symmetric-encryption' # model.rb
 attr_encrypted :bank_account_number
 attr_encrypted :values, type: :json 

  11. # remove barriers to getting code
 # into production, even

    if the feature
 # isn’t finished # Gemfile
 gem ‘flipper'
 gem ‘flipper-redis‘
 gem ‘flipper-ui‘ # view.html.slim
 - if $flipper[:new_signup_page].enabled? (current_user)
 = link_to ‘Sign Up’, new_signup_path

  12. # control access to certain features # Gemfile
 gem ‘rolify’


    gem ‘pundit’ # view || controller
 - if current_user.has_role?(:admin)
 …
 - if policy(@record).update?
 …
  13. # Gemfile
 gem ‘pretender' # view || controller
 true_user
 current_user

    # application_controller.rb
 def impersonating?
 true_user != current_user
 end