aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/generators
Commit message (Collapse)AuthorAgeFilesLines
* Enable `Performance/UnfreezeString` copyuuji.yaginuma2018-09-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`. ```ruby # frozen_string_literal: true require "bundler/inline" gemfile(true) do source "https://rubygems.org" gem "benchmark-ips" end Benchmark.ips do |x| x.report('+@') { +"" } x.report('dup') { "".dup } x.compare! end ``` ``` $ ruby -v benchmark.rb ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux] Warming up -------------------------------------- +@ 282.289k i/100ms dup 187.638k i/100ms Calculating ------------------------------------- +@ 6.775M (± 3.6%) i/s - 33.875M in 5.006253s dup 3.320M (± 2.2%) i/s - 16.700M in 5.032125s Comparison: +@: 6775299.3 i/s dup: 3320400.7 i/s - 2.04x slower ```
* Remove mysql2 gem version requirement "< 0.6.0"Yasuo Honda2018-09-141-1/+1
| | | | Suggested at https://github.com/rails/rails/pull/33876#issuecomment-421176221
* Bump MySQL version requirement to 5.5.8 in the template filesYasuo Honda2018-09-132-2/+2
| | | | Follow-up #33853
* Validate if `utf8mb4` character set and longer index key prefix is supportedYasuo Honda2018-09-131-1/+0
| | | | | | | | | | | Once #33608 merged If users create a new database using MySQL 5.1.x, it will fail to create databases since MySQL 5.1 does not know `utf8mb4` character set. This pull request removes `encoding: utf8mb4` from `mysql.yml.tt` to let create_database method handles default character set by MySQL server version. `supports_longer_index_key_prefix?` method will need to validate if MySQL 5.5 and 5.6 server configured correctly to support longer index key prefix, but not yet.
* use "minitest" consistentlyXavier Noria2018-09-111-2/+1
| | | | | | | | | The name of the minitest library is spelled that way: regular font, and lowercase. Lowercase is used even at the beginning of sentences, see http://docs.seattlerb.org/minitest/ I double-checked this with @zenspider too (thanks!).
* Use utf8mb4 character set by default for MySQL database (#33608)Yasuo Honda2018-09-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Use utf8mb4 character set by default `utf8mb4` character set supports supplementary characters including emoji. `utf8` character set with 3-Byte encoding is not enough to support them. There was a downside of 4-Byte length character set with MySQL 5.5 and 5.6: "ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes" for Rails string data type which is mapped to varchar(255) type. MySQL 5.7 supports 3072 byte key prefix length by default. * Remove `DEFAULT COLLATE` from Active Record unit test databases There should be no "one size fits all" collation in MySQL 5.7. Let MySQL server choose the default collation for Active Record unit test databases. Users can choose their best collation for their databases by setting `options[:collation]` based on their requirements. * InnoDB FULLTEXT indexes support since MySQL 5.6 it does not have to use MyISAM storage engine whose maximum key length is 1000 bytes. Using MyISAM storag engine with utf8mb4 character set would cause "Specified key was too long; max key length is 1000 bytes" https://dev.mysql.com/doc/refman/5.6/en/innodb-fulltext-index.html * References "10.9.1 The utf8mb4 Character Set (4-Byte UTF-8 Unicode Encoding)" https://dev.mysql.com/doc/refman/5.7/en/charset-unicode-utf8mb4.html "10.9.2 The utf8mb3 Character Set (3-Byte UTF-8 Unicode Encoding)" https://dev.mysql.com/doc/refman/5.7/en/charset-unicode-utf8.html "14.8.1.7 Limits on InnoDB Tables" https://dev.mysql.com/doc/refman/5.7/en/innodb-restrictions.html > If innodb_large_prefix is enabled (the default), the index key prefix limit is 3072 bytes > for InnoDB tables that use DYNAMIC or COMPRESSED row format. * CI against MySQL 5.7 Followed this instruction and changed root password to empty string. https://docs.travis-ci.com/user/database-setup/#MySQL-57 * The recommended minimum version of MySQL is 5.7.9 to support utf8mb4 character set and `innodb_default_row_format` MySQL 5.7.9 introduces `innodb_default_row_format` to support 3072 byte length index by default. Users do not have to change MySQL database configuration to support Rails string type. https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_default_row_format https://dev.mysql.com/doc/refman/5.7/en/innodb-restrictions.html > If innodb_large_prefix is enabled (the default), > the index key prefix limit is 3072 bytes for InnoDB tables that use DYNAMIC or COMPRESSED row format. * The recommended minimum version of MariaDB is 10.2.2 MariaDB 10.2.2 is the first version of MariaDB supporting `innodb_default_row_format` Also MariaDB says "MySQL 5.7 is compatible with MariaDB 10.2". - innodb_default_row_format https://mariadb.com/kb/en/library/xtradbinnodb-server-system-variables/#innodb_default_row_format - "MariaDB versus MySQL - Compatibility" https://mariadb.com/kb/en/library/mariadb-vs-mysql-compatibility/ > MySQL 5.7 is compatible with MariaDB 10.2 - "Supported Character Sets and Collations" https://mariadb.com/kb/en/library/supported-character-sets-and-collations/
* Use canonical name for block localyuuji.yaginuma2018-09-071-12/+12
| | | | | | | | `spec` is the same variable name as gemspec generated by bundler, and its intention is easier to understand than a one-letter variable. https://github.com/bundler/bundler/blob/00fd58eaa69015092ee272c4cb5aa92a5e7ee45c/lib/bundler/templates/newgem/newgem.gemspec.tt#L11 This is follow up on 1c59b4840c58097186022f68427c46e0046c5d0d. `spec` is already in use there.
* Generate a gem that can't be pushed to Rubygems.org by defaultRafael Mendonça França2018-09-061-0/+9
| | | | | This will avoid gems that are made to be private to be pushed to public repositories.
* Merge pull request #33773 from mcnelson/null_cache_store_for_test_envGeorge Claghorn2018-09-021-0/+1
|\ | | | | Make null_store the default cache store in test environment config
| * Set cache store as null_store for test environmentMichael Nelson2018-08-021-0/+1
| |
* | Merge pull request #33743 from ↵Rafael França2018-08-311-15/+41
|\ \ | | | | | | | | | | | | steakknife/steakknife/improve-template-generator-actions add github to template actions, template actions minor refactor
| * | add github to template actions, light DSL refactorBarry Allard2018-08-301-15/+41
| | |
* | | Emit warning for unknown inflection rule when generating model.Yoshiyuki Kinjo2018-08-311-1/+8
|/ / | | | | | | | | | | For words like "abuse", Rails cannot derive its singular form from plural form "abuses" without defining custom inflection rule. `rails generate model` and its families now emit warning for this case.
* | Generate the same value as a label of view in system test templateyuuji.yaginuma2018-08-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the system test template, enter a value based on label. However, since `label` method does not use `titleize` by default. If generate a value including underscore, cannot find a label and the test will fail. ``` $ ./bin/rails g scaffold user name:string phone_number:string $ ./bin/rails t test/system/users_test.rb E Error: UsersTest#test_creating_a_User: Capybara::ElementNotFound: Unable to find field "Phone Number" test/system/users_test.rb:18:in `block in <class:UsersTest>' ``` This removes unnecessary `titleize` so that the generated file will pass even if the attribute contains an underscore.
* | Set the test adapter for the test environment by default in `config/cable.yml`bogdanvlviv2018-08-231-1/+1
| |
* | Purpose Metadata For Signed And Encrypted CookiesAssain2018-08-121-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Purpose metadata prevents cookie values from being copy-pasted and ensures that the cookie is used only for its originally intended purpose. The Purpose and Expiry metadata are embedded inside signed/encrypted cookies and will not be readable on previous versions of Rails. We can switch off purpose and expiry metadata embedded in signed and encrypted cookies using config.action_dispatch.use_cookies_with_metadata = false if you want your cookies to be readable on older versions of Rails.
* | Merge pull request #33587 from bogdanvlviv/follow-up-33202Kasper Timm Hansen2018-08-111-3/+2
|\ \ | | | | | | `bundle binstubs bundler` should be executed after `bundle install`
| * | `bundle binstubs bundler` should be executed after `bundle install`bogdanvlviv2018-08-111-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes: `bundle binstubs bundler` doesn't generate `bin/bundle` for newly generated Rails app. ``` ... (snip) run bundle binstubs bundler The git source https://github.com/rails/web-console.git is not yet checked out. Please run `bundle install` before trying to start your application run bundle install Fetching https://github.com/rails/web-console.git (snip) ... ``` Related to #33202
* | | Make active job name prefix static since Rails.env will always be the sameVinicius Stock2018-08-111-1/+1
|/ /
* | Merge pull request #33202 from deivid-rodriguez/bundler_binstubsEileen M. Uchitelle2018-08-113-2/+8
|\ \ | |/ |/| Bundler binstubs
| * Generate bundler-compatible bundler binstubDavid Rodríguez2018-06-233-2/+8
| |
* | Enable Start/EndWith and RegexpMatch copsBart de Water2018-07-283-5/+5
| | | | | | | | | | In cases where the MatchData object is not used, this provides a speed-up: https://github.com/JuanitoFatas/fast-ruby/#stringmatch-vs-stringmatch-vs-stringstart_withstringend_with-code-start-code-end
* | Merge pull request #32381 from q-centrix/update-codeclimate-configsRichard Schneeman2018-07-251-1/+1
|\ \ | | | | | | Turn on performance based cops
| * | Turn on performance based copsDillon Welch2018-07-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use attr_reader/attr_writer instead of methods method is 12% slower Use flat_map over map.flatten(1) flatten is 66% slower Use hash[]= instead of hash.merge! with single arguments merge! is 166% slower See https://github.com/rails/rails/pull/32337 for more conversation
* | | Merge pull request #33229 from ↵Matthew Draper2018-07-253-5/+5
|\ \ \ | | | | | | | | | | | | | | | | albertoalmagro/albertoalmagro/prefer-rails-command-over-bin-rails Prefer rails command over bin/rails
| * | | Recommend use of rails over bin/railsAlberto Almagro2018-07-063-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As discussed in #33203 rails command already looks for, and runs, bin/rails if it is present. We were mixing recommendations within guides and USAGE guidelines, in some files we recommended using rails, in others bin/rails and in some cases we even had both options mixed together.
* | | | Rails guides are now served over httpsPaul McMahon2018-07-2412-13/+13
| |/ / |/| | | | | | | | | | | http links will be redirected to the https version, but still better to just directly link to the https version.
* | | Merge pull request #32984 from chiraggshah/min-thread-env-variableRichard Schneeman2018-07-211-2/+3
|\ \ \ | |/ / |/| | Separate min and max threads count environment variable for puma configuration
| * | Modified the changes to make it backward compatibleChirag Shah2018-07-211-1/+1
| | |
| * | Separate min and max threads count for pumaChirag Shah2018-05-251-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Same environment variable RAILS_MAX_THREADS was being used for setting the minimum and maximum thread count for puma. This change makes it obvious and easy to decide which environment variable to change for setting the min or max. Don't feel like this is a breaking change as the same default is maintained.
* | | Remove old TODO commentAlberto Almagro2018-07-041-1/+0
| | | | | | | | | | | | | | | This TODO comment has been here more than 7 years and doesn't seem to be a temporary implementation anymore.
* | | Merge pull request #32706 from ↵Kasper Timm Hansen2018-07-011-5/+9
|\ \ \ | |_|/ |/| | | | | | | | yhirano55/fix-app-update-when-hyphenated-name-is-given Fix app:update when hyphenated name is given
| * | Fix app:update when hyphenated name is givenYoshiyuki Hirano2018-04-241-5/+9
| | | | | | | | | | | | | | | | | | * Fixed app_name's difference between `rails new` and `app:update` * Changed be prefer to const name than directory name. * Kept original app name which use exception message.
* | | OS X -> macOS [Closes #30313]Xavier Noria2018-06-231-2/+2
| | | | | | | | | | | | [Jon Moss & Xavier Noria]
* | | Fix Ruby version in `.ruby-version`bogdanvlviv2018-06-181-1/+1
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since #30016 Rails generates `.ruby-version` file in order to help Ruby version manager tools like `rbenv`, `rvm` determine which Ruby version should be used for the current Rails project. Since #32649 Rails sets Ruby version to the file compatible with MRI/JRuby by default. Pull Request #31496 reports that `.ruby-version` doesn't match ruby version other than stable version and recommends to use `ENV["RBENV_VERSION"]`, and `ENV["rvm_ruby_string"]` in order to set correct Ruby version to the file that `rbenv` or `rvm` can understand. Also, there is another similar issue that reports the same case if use JRuby https://github.com/jruby/jruby/issues/5144. Closes #31496, https://github.com/jruby/jruby/issues/5144.
* | Merge pull request #30406 from eliotsykes/reduce-spring-watch-callsRafael Mendonça França2018-05-231-6/+6
|\ \ | | | | | | | | | Minimize Spring.watch calls
| * | Minimize Spring.watch callsEliot Sykes2017-08-251-6/+6
| | |
* | | Don't generate yarn's contents in `app:update` task if it's skippedTsukuru Tanimichi2018-05-161-3/+1
| | |
* | | Remove unused `remove_file` methodTsukuru Tanimichi2018-05-081-4/+0
| | | | | | | | | | | | | | | | | | In #32780, We have supported the `--skip-sprockets` option in the `app:update` task. When `options[:api]` is truthy, `option[:skip_sprockets]` is also truthy. So we can remove this `remove_file` method. https://github.com/rails/rails/blob/42b9e7e50c084e119a679cf155b70b5efc4d36ff/railties/lib/rails/generators/rails/app/app_generator.rb#L281-L283
* | | Don't generate assets' initializer in `app:update` task if sprockets is skippedTsukuru Tanimichi2018-05-051-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Execute `rails new myapp -S` and then upgrade the app by using the `app:update` task, `bin/rails c` results in `NoMethodError`. ``` $ bin/rails app:update $ bin/rails c Traceback (most recent call last): 44: from bin/rails:4:in `<main>' (snip) 1: from /Users/tanimichi.tsukuru/ghq/github.com/moneyforward/moneyplus/config/initializers/assets.rb:4:in `<top (required)>' /Users/tanimichi.tsukuru/ghq/github.com/moneyforward/moneyplus/vendor/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/railtie/configuration.rb:97:in `method_missing': undefined method `assets' for #<Rails::Application::Configuration:0x00007fcb8d3697e0> (NoMethodError) Did you mean? asset_host ```
* | | Merge pull request #32471 from janko-m/use-image_processing-gemGeorge Claghorn2018-04-231-1/+1
|\ \ \ | |_|/ |/| | Use ImageProcessing gem for ActiveStorage variants
| * | Use ImageProcessing gem for ActiveStorage variantsJanko Marohnić2018-04-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ImageProcessing gem is a wrapper around MiniMagick and ruby-vips, and implements an interface for common image resizing and processing. This is the canonical image processing gem recommended in [Shrine], and that's where it developed from. The initial implementation was extracted from Refile, which also implements on-the-fly transformations. Some features that ImageProcessing gem adds on top of MiniMagick: * resizing macros - #resize_to_limit - #resize_to_fit - #resize_to_fill - #resize_and_pad * automatic orientation * automatic thumbnail sharpening * avoids the complex and inefficient MiniMagick::Image class * will use "magick" instead of "convert" on ImageMagick 7 However, the biggest feature of the ImageProcessing gem is that it has an alternative implementation that uses libvips. Libvips is an alternative to ImageMagick that can process images very rapidly (we've seen up 10x faster than ImageMagick). What's great is that the ImageProcessing gem provides the same interface for both implementations. The macros are named the same, and the libvips implementation does auto orientation and thumbnail sharpening as well; only the operations/options specific to ImageMagick/libvips differ. The integration provided by this PR should work for both implementations. The plan is to introduce the ImageProcessing backend in Rails 6.0 as the default backend and deprecate the MiniMagick backend, then in Rails 6.1 remove the MiniMagick backend.
* | | Merge pull request #31554 from fatkodima/controller_generator_suffixGuillermo Iguaran2018-04-221-1/+11
|\ \ \ | | | | | | | | Gracefully handle extra "controller" when generating controller
| * | | Gracefully handle extra "controller" when generating controllerfatkodima2018-03-231-1/+11
| | | |
* | | | Strip duplicated suffixes more strictlyRyuta Kamizono2018-04-223-3/+3
| | | | | | | | | | | | | | | | In the previous code incorrectly removes intermediate words.
* | | | Fix duplicated suffix for JobGeneratorYoshiyuki Hirano2018-04-221-0/+5
| | | |
* | | | Don't include bootsnap by default in apps generated under JRubyGuillermo Iguaran2018-04-201-1/+1
| | | |
* | | | Create a .ruby-version compatible with MRI/JRuby by defaultGuillermo Iguaran2018-04-191-1/+1
| | | |
* | | | Make the master.key readable only by the ownerJose Luis Duran2018-04-191-0/+1
| |/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change may only apply to POSIX-compliant systems. Previously: $ ls -l config/master.key -rw-r--r-- 1 owner group 32 Jan 1 00:00 master.key Now: $ ls -l config/master.key -rw------- 1 owner group 32 Jan 1 00:00 master.key
* | | Add .keep exception for storage folderPaul2018-04-131-1/+4
| | | | | | | | | Fixes https://github.com/rails/rails/issues/32546 by including the `.keep` file in the .gitignore, bringing the `storage` folder in line with the `tmp` and `log` folders.