My opinionated ruby on rails template
at main 69 lines 1.8 kB view raw
1# frozen_string_literal: true 2 3say 'Installing development tools...', :green 4 5# Development and debugging gems 6gem_group :development do 7 gem 'pry-rails' 8 gem 'bullet' 9 gem 'query_count' 10 gem 'actual_db_schema' 11 gem 'annotaterb' 12 gem 'letter_opener_web' 13 gem 'rack-mini-profiler', require: false 14end 15 16# Rack Mini Profiler configuration 17initializer 'rack_mini_profiler.rb', <<~RUBY 18 # frozen_string_literal: true 19 20 if defined?(Rack::MiniProfiler) && Rails.env.development? 21 require 'rack-mini-profiler' 22 Rack::MiniProfilerRails.initialize!(Rails.application) 23 end 24RUBY 25 26# Bullet configuration for N+1 query detection 27initializer 'bullet.rb', <<~RUBY 28 # frozen_string_literal: true 29 30 if defined?(Bullet) && Rails.env.development? 31 Rails.application.configure do 32 config.after_initialize do 33 Bullet.enable = true 34 Bullet.alert = false 35 Bullet.bullet_logger = true 36 Bullet.console = true 37 Bullet.rails_logger = true 38 Bullet.add_footer = true 39 end 40 end 41 end 42RUBY 43 44# Letter Opener Web for email preview in development 45route <<~RUBY 46 if Rails.env.development? 47 mount LetterOpenerWeb::Engine, at: '/letter_opener' 48 end 49RUBY 50 51inject_into_file 'config/environments/development.rb', before: /^end$/ do 52 <<~RUBY 53 54 # Use letter_opener for email delivery 55 config.action_mailer.delivery_method = :letter_opener_web 56 config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } 57 RUBY 58end 59 60# Run generators after bundle 61after_bundle do 62 say ' Running AnnotateRb installer...', :cyan 63 rails_command 'generate annotate_rb:install' 64 65 say ' Running Bullet installer...', :cyan 66 rails_command 'generate bullet:install' 67end 68 69say 'Development tools installed!', :green