aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/generators
Commit message (Collapse)AuthorAgeFilesLines
* Keep new line after the last dependencyyuuji.yaginuma2018-11-041-1/+1
| | | | | If add a package with `yarn`, it will have a newline after the last dependency so let's match with that.
* Restore `encoding: utf8mb4` in database.ymlYasuo Honda2018-10-301-0/+1
| | | | | | | rails/rails#33853 and rails/rails#33929 removed `encoding: utf8mb4` from database.yml since at that time MySQL 5.1 is supported with the master branch. Since MySQL 5.1 has been dropped, we can restore `encoding: utf8mb4` in database.yml
* Merge pull request #34275 from bogdanvlviv/skip_yarn-to-skip_javascriptRafael França2018-10-237-18/+11
|\ | | | | Remove `--skip-yarn` in favor of `--skip-javascript`
| * Remove node_modules path from assets load paths since we use webpack by defaultbogdanvlviv2018-10-221-4/+0
| | | | | | | | Related to #33079
| * Remove `--skip-yarn` in favor of `--skip-javascript`bogdanvlviv2018-10-227-15/+12
| | | | | | | | | | | | Since #33079 Webpacker the default JavaScript compiler for Rails. Webpacker uses `yarn` so seems like it doesn't make sense for Rails to keep `--skip-yarn` option.
* | Add missing dot in comment in .gitignore templateJochem Schulenklopper2018-10-221-1/+1
|/ | | | My submission for the tiniest commit and PR contest: add a missing dot in a comment line in the generator template for .gitignore. (I just noticed this missing; consistency is king :-)
* Merge pull request #34279 from ↵Ryuta Kamizono2018-10-221-1/+0
|\ | | | | | | | | bogdanvlviv/remove-extra-remove_file-skip_action_cable Remove extra call `remove_file` on `rails new` with `--skip_action_cable`
| * Remove extra call `remove_file` on `rails new` with `--skip_action_cable`bogdanvlviv2018-10-221-1/+0
| | | | | | | | | | There is no need to remove this file since the line below removes entire directory in which that file is placed.
* | Merge pull request #34274 from ↵Ryuta Kamizono2018-10-221-6/+1
|\ \ | |/ |/| | | | | bogdanvlviv/remove-yarn-files-from-gitignore-template Remove yarn's files from `.gitignore` template
| * Remove yarn's files from `.gitignore` template for new rails appbogdanvlviv2018-10-211-6/+1
| | | | | | | | | | | | | | | | Webpacker already does it, see https://github.com/rails/webpacker/blob/895d2cfc15eda2edae9e667c642a02523d958f53/lib/install/template.rb#L25-L33 I also opened PR https://github.com/rails/webpacker/pull/1765 in order to make it add `/yarn-error.log` file too.
* | Remove `:javascript` from `Rails::PluginBuilder::PASSTHROUGH_OPTIONS`bogdanvlviv2018-10-221-1/+1
|/ | | | `--javascript` option was removed by 42198064c35ff3b701496309f90df2abc229efbe
* Remove unnecessary escape characterFrancesco Rodríguez2018-10-191-2/+2
|
* Fix generated Gemfile missing gems on jrubyDavid Rodríguez2018-10-171-1/+1
|
* Show object ids in scaffold pages when displaying referenced objectsRasesh Patel2018-10-142-2/+2
| | | | | | | | | | | | Resolve Issue#29200 When scaffolding a model that references another model the generated show and index html pages display the object directly on the page. Basically, it just shows a memory address. That is not very helpful. In this commit we show the object's id rather than the memory address. This updates the scaffold templates and the json builder files.
* Use `--skip-webpack-install` by defaultyuuji.yaginuma2018-10-091-1/+1
| | | | To remove extra `--no-skip-javascript` tests.
* Avoid `webpacker:install` if unnecessaryyuuji.yaginuma2018-10-091-0/+1
| | | | | `webpacker:install` also includes execution of yarn, it takes time to execute, so avoid unnecessary tests.
* Add `skip-webpack-install` optionyuuji.yaginuma2018-10-092-1/+8
| | | | | This option is useful when want to check only the files generated by `rails new`, or if want to do something before `webpacker:install`.
* Merge pull request #34084 from trustvox/masterRafael França2018-10-052-4/+2
|\ | | | | Remove "include FileUtils" sentence in setup/update bin files
| * Remove "include FileUtils" sentence in setup/update bin filesBruno Casali2018-09-172-4/+2
| | | | | | | | | | According with rubocop style guide "Style/MixinUsage" is good to use only in class/module not directly in file.
* | Add retry_on/discard suggestions for common cases.Francesco Rodríguez2018-10-051-0/+5
| | | | | | | | | | | | | | | | This adds the same suggestions added here: https://github.com/rails/rails/blob/01a69e27a4e55504af8fe776826d659550e6f89e/activejob/lib/rails/generators/job/templates/application_job.rb These appear when `app/jobs/application_job.rb` doesn't exist, but not for new applications.
* | Make Webpacker the default JavaScript compiler for Rails 6 (#33079)David Heinemeier Hansson2018-09-3017-126/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Use Webpacker by default on new apps * Stop including coffee-rails by default * Drop using a js_compressor by default * Drop extra test for coffeescript inclusion by default * Stick with skip_javascript to signify skipping webpack * Don't install a JS runtime by default any more * app/javascript will be the new default directory for JS * Make it clear that this is just for configuring the default Webpack framework setup now * Start using the Webpack tag in the default layout * Irrelevant test * jQuery is long gone * Stop having asset pipeline compile default application.js * Add rails-ujs by default to the Webpack setup * Add Active Storage JavaScript to application.js pack by default * Consistent quoting * Add Turbolinks to default pack * Add Action Cable to default pack Need some work on how to set the global consumer that channels will work with. @javan? * Require all channels by default and use a separate consumer stub * Channel generator now targets Webpack style * Update task docs to match new generator style * Use uniform import style * Drop the JS assets generator It was barely helpful as it was. It’s no longer helpful in a Webpacked world. Sayonara! * Add app/javascript to the stats directories * Simpler import style Which match the other imports. * Address test failures from dropping JS compilation (and compression) * webpacker-default: Modify `AssetsGeneratorTest` Before: ``` $ bin/test test/generators/assets_generator_test.rb Run options: --seed 46201 F Failure: AssetsGeneratorTest#test_assets [/Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/assets_generator_test.rb:12]: Expected file "app/assets/javascripts/posts.js" to exist, but does not bin/test /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/assets_generator_test.rb:10 . Finished in 0.031343s, 63.8101 runs/s, 95.7152 assertions/s. 2 runs, 3 assertions, 1 failures, 0 errors, 0 skips ``` After: ``` $ bin/test test/generators/assets_generator_test.rb Run options: --seed 43571 .. Finished in 0.030370s, 65.8545 runs/s, 65.8545 assertions/s. 2 runs, 2 assertions, 0 failures, 0 errors, 0 skips ``` * webpacker-default: Modify `ChannelGeneratorTest` Before: ``` $ bin/test test/generators/channel_generator_test.rb Run options: --seed 8986 .F Failure: ChannelGeneratorTest#test_channel_with_multiple_actions_is_created [/Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:43]: Expected file "app/assets/javascripts/channels/chat.js" to exist, but does not bin/test /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:34 .F Failure: ChannelGeneratorTest#test_channel_is_created [/Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:29]: Expected file "app/assets/javascripts/channels/chat.js" to exist, but does not bin/test /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:22 E Error: ChannelGeneratorTest#test_cable_js_is_created_if_not_present_already: Errno::ENOENT: No such file or directory @ apply2files - /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/fixtures/tmp/app/assets/javascripts/cable.js bin/test /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:60 F Failure: ChannelGeneratorTest#test_channel_suffix_is_not_duplicated [/Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:87]: Expected file "app/assets/javascripts/channels/chat.js" to exist, but does not bin/test /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:80 F Failure: ChannelGeneratorTest#test_channel_on_revoke [/Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:77]: Expected file "app/assets/javascripts/cable.js" to exist, but does not bin/test /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:68 Finished in 0.064384s, 108.7227 runs/s, 481.4861 assertions/s. 7 runs, 31 assertions, 4 failures, 1 errors, 0 skips ``` After: ``` $ bin/test test/generators/channel_generator_test.rb Run options: --seed 44857 ....... Finished in 0.060243s, 116.1961 runs/s, 697.1764 assertions/s. 7 runs, 42 assertions, 0 failures, 0 errors, 0 skips ``` * Fix shared generator tests. * webpacker-default: Modify `ControllerGeneratorTest` The JS assets generator was dropped. ref. https://github.com/rails/rails/commit/46215b179483d3e4d264555f5a4952f43eb8142a * Revert "Simpler import style". It's currently failing with an error of "TypeError: undefined is not an object (evaluating '__WEBPACK_IMPORTED_MODULE_2_activestorage___default.a.start')". Waiting for @javan to have a look. This reverts commit 5d3ebb71059f635d3756cbda4ab9752027e09256. * require webpacker in test app * Add webpacker without making the build hang/timeout. (#33640) * use yarn workspaces to allow for installing unreleased packages and only generate js/bootsnap when required * no longer need to have webpacker in env templates as webpacker moved this config to yml file * Fix rubocop violation * Got the test passing for the running scaffold * update expected lines of code * update middleware tests to account for webpacker * disable js in plugins be default to get the tests passing (#34009) * clear codeclimate report issues * Anything newer than currently released is good * Use Webpacker development version during development of Rails * Edge should get development webpacker as well * Add changelog entry for Webpacker change
* | 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
| | |