├── .rubocop.yml ├── README.md ├── LICENSE ├── minimal.rb └── devise.rb /.rubocop.yml: -------------------------------------------------------------------------------- 1 | AllCops: 2 | NewCops: enable 3 | Exclude: 4 | - 'bin/**/*' 5 | - 'db/**/*' 6 | - 'config/**/*' 7 | - 'node_modules/**/*' 8 | - 'script/**/*' 9 | - 'support/**/*' 10 | - 'tmp/**/*' 11 | - 'test/**/*' 12 | 13 | Style/ConditionalAssignment: 14 | Enabled: false 15 | Style/StringLiterals: 16 | Enabled: false 17 | Style/RedundantReturn: 18 | Enabled: false 19 | Style/Documentation: 20 | Enabled: false 21 | Style/WordArray: 22 | Enabled: false 23 | Metrics/AbcSize: 24 | Enabled: false 25 | Style/MutableConstant: 26 | Enabled: false 27 | Style/SignalException: 28 | Enabled: false 29 | Metrics/CyclomaticComplexity: 30 | Enabled: false 31 | Style/MissingRespondToMissing: 32 | Enabled: false 33 | Lint/MissingSuper: 34 | Enabled: false 35 | Style/FrozenStringLiteralComment: 36 | Enabled: false 37 | Layout/LineLength: 38 | Max: 120 39 | Style/EmptyMethod: 40 | Enabled: false 41 | Bundler/OrderedGems: 42 | Enabled: false 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rails Templates 2 | 3 | Quickly generate a rails app with the default [Wagon](https://www.lewagon.com) configuration 4 | using [Rails Templates](http://guides.rubyonrails.org/rails_application_templates.html). 5 | 6 | ⚠️ The following templates have been made for Rails 7. If you use Rails 6, please refer to the [`no-update` branch templates](https://github.com/lewagon/rails-templates/tree/no-update) 7 | 8 | ## Minimal 9 | 10 | Get a minimal rails app ready to be deployed on Heroku with Bootstrap, Simple form and debugging gems. 11 | 12 | ```bash 13 | rails new \ 14 | -d postgresql \ 15 | -m https://raw.githubusercontent.com/lewagon/rails-templates/master/minimal.rb \ 16 | CHANGE_THIS_TO_YOUR_RAILS_APP_NAME 17 | ``` 18 | 19 | ## Devise 20 | 21 | Same as minimal **plus** a Devise install with a generated `User` model. 22 | 23 | ```bash 24 | rails new \ 25 | -d postgresql \ 26 | -m https://raw.githubusercontent.com/lewagon/rails-templates/master/devise.rb \ 27 | CHANGE_THIS_TO_YOUR_RAILS_APP_NAME 28 | ``` 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2017 Le Wagon 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /minimal.rb: -------------------------------------------------------------------------------- 1 | run "if uname | grep -q 'Darwin'; then pgrep spring | xargs kill -9; fi" 2 | 3 | # Gemfile 4 | ######################################## 5 | inject_into_file "Gemfile", before: "group :development, :test do" do 6 | <<~RUBY 7 | gem "bootstrap", "~> 5.3" 8 | gem "autoprefixer-rails" 9 | gem "font-awesome-sass", "~> 6.1" 10 | gem "simple_form", github: "heartcombo/simple_form" 11 | gem "sassc-rails" 12 | 13 | RUBY 14 | end 15 | 16 | inject_into_file "Gemfile", after: "group :development, :test do" do 17 | "\n gem \"dotenv-rails\"" 18 | end 19 | 20 | # Assets 21 | ######################################## 22 | run "rm -rf app/assets/stylesheets" 23 | run "rm -rf vendor" 24 | run "curl -L https://github.com/lewagon/rails-stylesheets/archive/master.zip > stylesheets.zip" 25 | run "unzip stylesheets.zip -d app/assets && rm -f stylesheets.zip && rm -f app/assets/rails-stylesheets-master/README.md" 26 | run "mv app/assets/rails-stylesheets-master app/assets/stylesheets" 27 | 28 | # Layout 29 | ######################################## 30 | 31 | gsub_file( 32 | "app/views/layouts/application.html.erb", 33 | '', 34 | '' 35 | ) 36 | 37 | # README 38 | ######################################## 39 | markdown_file_content = <<~MARKDOWN 40 | Rails app generated with [lewagon/rails-templates](https://github.com/lewagon/rails-templates), created by the [Le Wagon coding bootcamp](https://www.lewagon.com) team. 41 | MARKDOWN 42 | file "README.md", markdown_file_content, force: true 43 | 44 | # Generators 45 | ######################################## 46 | generators = <<~RUBY 47 | config.generators do |generate| 48 | generate.assets false 49 | generate.helper false 50 | generate.test_framework :test_unit, fixture: false 51 | end 52 | 53 | RUBY 54 | 55 | environment generators 56 | 57 | # General Config 58 | ######################################## 59 | general_config = <<~RUBY 60 | config.action_controller.raise_on_missing_callback_actions = false if Rails.version >= "7.1.0" 61 | RUBY 62 | 63 | environment general_config 64 | 65 | ######################################## 66 | # After bundle 67 | ######################################## 68 | after_bundle do 69 | # Generators: db + simple form + pages controller 70 | ######################################## 71 | rails_command "db:drop db:create db:migrate" 72 | generate("simple_form:install", "--bootstrap") 73 | generate(:controller, "pages", "home", "--skip-routes", "--no-test-framework") 74 | 75 | # Routes 76 | ######################################## 77 | route 'root to: "pages#home"' 78 | 79 | # Gitignore 80 | ######################################## 81 | append_file ".gitignore", <<~TXT 82 | 83 | # Ignore .env file containing credentials. 84 | .env* 85 | 86 | # Ignore Mac and Linux file system files 87 | *.swp 88 | .DS_Store 89 | TXT 90 | 91 | # Bootstrap & Popper 92 | ######################################## 93 | append_file "config/importmap.rb", <<~RUBY 94 | pin "bootstrap", to: "bootstrap.min.js", preload: true 95 | pin "@popperjs/core", to: "popper.js", preload: true 96 | RUBY 97 | 98 | append_file "config/initializers/assets.rb", <<~RUBY 99 | Rails.application.config.assets.precompile += %w(bootstrap.min.js popper.js) 100 | RUBY 101 | 102 | append_file "app/javascript/application.js", <<~JS 103 | import "@popperjs/core" 104 | import "bootstrap" 105 | JS 106 | 107 | append_file "app/assets/config/manifest.js", <<~JS 108 | //= link popper.js 109 | //= link bootstrap.min.js 110 | JS 111 | 112 | # Heroku 113 | run "bundle lock --add-platform x86_64-linux" 114 | 115 | # Dotenv 116 | ######################################## 117 | run "touch '.env'" 118 | 119 | # Rubocop 120 | ######################################## 121 | run "curl -L https://raw.githubusercontent.com/lewagon/rails-templates/master/.rubocop.yml > .rubocop.yml" 122 | 123 | # Git 124 | ######################################## 125 | git :init 126 | git add: "." 127 | git commit: "-m 'Initial commit with minimal template from https://github.com/lewagon/rails-templates'" 128 | end 129 | -------------------------------------------------------------------------------- /devise.rb: -------------------------------------------------------------------------------- 1 | run "if uname | grep -q 'Darwin'; then pgrep spring | xargs kill -9; fi" 2 | 3 | # Gemfile 4 | ######################################## 5 | inject_into_file "Gemfile", before: "group :development, :test do" do 6 | <<~RUBY 7 | gem "bootstrap", "~> 5.3" 8 | gem "devise" 9 | gem "autoprefixer-rails" 10 | gem "font-awesome-sass", "~> 6.1" 11 | gem "simple_form", github: "heartcombo/simple_form" 12 | gem "sassc-rails" 13 | 14 | RUBY 15 | end 16 | 17 | inject_into_file "Gemfile", after: "group :development, :test do" do 18 | "\n gem \"dotenv-rails\"" 19 | end 20 | 21 | # Assets 22 | ######################################## 23 | run "rm -rf app/assets/stylesheets" 24 | run "rm -rf vendor" 25 | run "curl -L https://github.com/lewagon/rails-stylesheets/archive/master.zip > stylesheets.zip" 26 | run "unzip stylesheets.zip -d app/assets && rm -f stylesheets.zip && rm -f app/assets/rails-stylesheets-master/README.md" 27 | run "mv app/assets/rails-stylesheets-master app/assets/stylesheets" 28 | 29 | # Layout 30 | ######################################## 31 | 32 | gsub_file( 33 | "app/views/layouts/application.html.erb", 34 | '', 35 | '' 36 | ) 37 | 38 | # Flashes 39 | ######################################## 40 | file "app/views/shared/_flashes.html.erb", <<~HTML 41 | <% if notice %> 42 |
Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %>
139 | HTML 140 | button_to = <<~HTML 141 |