aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/generators/named_base.rb
Commit message (Collapse)AuthorAgeFilesLines
* Remove field ids from scaffold formyuuji.yaginuma2017-11-261-4/+0
| | | | | | This was added with 27f103fc7e3260efe0b8dde66bf5354f2202ee32 for link labels and fields. However, `form_with` changed to generates ids by default with d3893ec38ec61282c2598b01a298124356d6b35a. So I think that adding an explicit ids is unnecessary.
* Fix comment in `check_class_collision` [ci skip]yuuji.yaginuma2017-11-071-1/+1
| | | | `ScaffoldBase` was changed to `ResourceHelpers` by 0efedf2.
* Remove unused requireyuuji.yaginuma2017-11-061-1/+0
| | | | Since f182831, this file does not use methods added by `module/introspection`.
* Generate the correct path in nested scaffold generatoryuuji.yaginuma2017-11-051-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, namespaced scaffold generator will generate an incorrect path and the generated file will not work properly. ``` $ ./bin/rails g scaffold admin/user $ ./bin/rails db:migrate $ ./bin/rails t test/controllers # Running: E Error: Admin::UsersControllerTest#test_should_create_admin_user: NameError: undefined local variable or method `admin_admin_users_url' for #<Admin::UsersControllerTest:0x000055a59f25ff68> Did you mean? admin_users test/controllers/admin/users_controller_test.rb:20:in `block (2 levels) in <class:UsersControllerTest>' test/controllers/admin/users_controller_test.rb:19:in `block in <class:UsersControllerTest>' bin/rails test test/controllers/admin/users_controller_test.rb:18 ``` This is because combine `controller_class_path` and `singular_table_name` to generate route. https://github.com/rails/rails/blob/360698aa245b45349d1d1b12e1afb34759515e69/railties/lib/rails/generators/named_base.rb#L172 Normally, if using namspaced generator, table name already contains namespace. Therefore, adding `controller_class_path` adds extra namespace. Since it is special only when explicitly specifying `model-name`, it is modified to change the value only when `model-name`is specified. Follow up of #30729
* [Railties] require_relative => requireAkira Matsuda2017-10-211-2/+2
| | | | This basically reverts 618268b4b9382f4bcf004a945fe2d85c0bd03e32
* scaffold nested name controller should be fine.yalab2017-09-271-3/+32
|
* Adding frozen_string_literal pragma to Railties.Pat Allan2017-08-141-0/+2
|
* Move generator namespacing to BaseLisa Ugray2017-07-191-36/+0
| | | | | | | Generators need to be aware of namespace to work properly in engines. Methods to help with this lived in Rails::Generators::NamedBase. Moving them to Rails::Generators::Base (which NamedBase inherits from) allows a follow-up in which a namespace aware unnamed generator can be created.
* [Railties] require => require_relativeAkira Matsuda2017-07-011-2/+2
|
* Fix rubocop violationsyuuji.yaginuma2017-04-121-1/+1
|
* add field ids when generating a scaffold form.Yves Senn2017-03-261-0/+4
| | | | | | This is a follow up to a6d065e. When using `form_with` you must supply field ids manually. Since the scaffold generator is using labels we need to make sure that they are linked up properly.
* Fix generator command for nested (namespaced) rails engine (take 2)Fumiaki MATSUSHIMA2017-01-071-2/+6
| | | | | | | | | | | | | | | | | | | Rewrite https://github.com/rails/rails/pull/27550 085546df45 was reverted (b6ffb5efcb) because it change the return of `namespaced_path` from String to Array. ---------------- If we create nested (namespaced) rails engine such like bukkits-admin, `bin/rails g scaffold User name:string age:integer` will create `bukkits-admin/app/controllers/bukkits/users_controller.rb` but it should create `bukkits-admin/app/controllers/bukkits/admin/users_controller.rb`. In #6643, we changed `namespaced_path` as root path because we supposed application_controller is always in root but nested rails engine's application_controller will not.
* `self.` is not needed when calling its own instance methodAkira Matsuda2017-01-051-1/+1
| | | | Actually, private methods cannot be called with `self.`, so it's not just redundant, it's a bad habit in Ruby
* Revert "Merge pull request #27550 from ↵Rafael Mendonça França2017-01-031-2/+2
| | | | | | | | | mtsmfm/fix-generator-command-for-nested-rails-engine" This reverts commit 1e969bfb98b88799e2c759fce25a1d8cf00d7ce7, reversing changes made to a5041f267ded119c2d00b8786c2f2c1e3f93c8a1. Reason: It breaks the public API
* Fix generator command for nested (namespaced) rails engineFumiaki MATSUSHIMA2017-01-031-2/+2
| | | | | | | | | | | | | If we create nested (namespaced) rails engine such like bukkits-admin, `bin/rails g scaffold User name:string age:integer` will create `bukkits-admin/app/controllers/bukkits/users_controller.rb` but it should create `bukkits-admin/app/controllers/bukkits/admin/users_controller.rb`. In #6643, we changed `namespaced_path` as root path because we supposed application_controller is always in root but nested rails engine's application_controller will not.
* Privatize unneededly protected methods in RailtiesAkira Matsuda2016-12-251-36/+38
|
* Describe what we are protectingAkira Matsuda2016-12-231-0/+2
|
* Remove unused method `namespaced_file_path`Fumiaki MATSUSHIMA2016-12-141-4/+0
| | | | | | | | ``` $ git grep namespaced_file_path railties/lib/rails/generators/named_base.rb: def namespaced_file_path railties/lib/rails/generators/named_base.rb: @namespaced_file_path ||= namespaced_class_path.join("/") ```
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-1/+1
|
* Add three new rubocop rulesRafael Mendonça França2016-08-161-2/+2
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* code gardening: removes redundant selfsXavier Noria2016-08-081-1/+1
| | | | | | | | | A few have been left for aesthetic reasons, but have made a pass and removed most of them. Note that if the method `foo` returns an array, `foo << 1` is a regular push, nothing to do with assignments, so no self required.
* applies new string literal convention in railties/libXavier Noria2016-08-061-12/+12
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Cable: Generate .js or .coffee files while generating channel as per the ↵Prathamesh Sonpatki2016-05-171-0/+4
| | | | | | | | | | | | | | | | | | | | | javascript engine of the application - Now we will detect what javascript engine user is using and based on that we will generate either `.js` or `.coffee` version of the channel file. - This also needs a change in coffee-rails to override the `js_template` method. Related PR https://github.com/rails/coffee-rails/pull/72. - Currently coffee-rails gem sets `config.app_generators.javascript_engine` to `:coffee` and using this information we override the `js_template` to set the extension as `.coffee` in coffee-rails gem. - Using this approach, we can keep the `channel.js` and `channel.coffee` files in the Rails repository itself. - Additionally the `js_template` method can act as public interface for coffee-rails gem to hook into and change the extension to `.coffee` without maintaining the actual asset files. [Prathamesh Sonpatki, Matthew Draper]
* make generated controller test work correctlyyuuji.yaginuma2016-01-061-0/+4
| | | | | | | Since the `#file_name` that not consideration for the namespace, if generate a controller with a namespace, not the correct url helper generation, it had become an error to run the test. Modified to generate the correct url helper, even if it is produced a namespace with controller.
* Update test generators to use ActionDispatch::IntegrationTestAbdelkader Boudih2015-12-151-0/+12
| | | | | | | | | | | | In Rails 5.1 `ActionController::TestCase` will be moved out of Rails into it's own gem. Please use `ActionDispatch::IntegrationTest` going forward. This changes the generators to use `ActionDispatch::IntegrationTest` and the required URL setup (rather than symbols) for each of the controller actions. Updated fix to #22076.
* fix NoMethodError that occurs when generating scaffold inside full mode engineyuuji.yaginuma2015-06-281-0/+4
|
* [ci skip] Fix the Rails::Generators::NamedBase#template docRoque Pinel2015-06-151-2/+2
| | | | | Since #13612, `template` is no longer being used to generate migrations.
* respect `pluralize_table_names` when generate fixture file. fixes #19519yuuji.yaginuma2015-03-271-0/+4
|
* Fix description for application_name method - change simple to simplyPrathamesh Sonpatki2014-12-301-1/+1
| | | | [ci skip]
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-2/+2
|
* Add FIXME note about the thor bugRafael Mendonça França2014-05-241-0/+2
|
* Merge pull request #9083 from bronson/patch-1Rafael Mendonça França2014-05-241-1/+4
|\ | | | | | | avoid using alias in generators
| * avoid using alias in generatorsScott Bronson2013-01-251-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Ruby's alias produces public methods, causing a spurious Thor task to be created.  For example, this is the reason MigrationGenerator currently has two tasks:     > ActiveRecord::Generators::MigrationGenerator.all_tasks.keys     => ["singular_name", "create_migration_file"] singular_name was meant to be an attribute, not a task.  Because it's public, it gets called as a task every time the generator is invoked. The fix is to ensure all generator methods have the correct visibility.
* | avoiding iterations and calling of underscore on all elements of arrayAkshay Vishnoi2013-11-171-1/+1
| |
* | copy edits[ci skip]Vijay Dev2013-05-191-3/+1
| |
* | Added documentation for Rails::Generators::NamedBase.templateaditya-kapoor2013-05-141-0/+4
| |
* | add require to suppress warning; remove variableVipul A M2013-04-041-1/+1
| |
* | Add support for generate scaffold password:digestSam Ruby2013-03-131-0/+1
|/ | | | | | | | | | * adds password_digest attribute to the migration * adds has_secure_password to the model * adds password and password_confirmation password_fields to _form.html * omits password entirely from index.html and show.html * adds password and password_confirmation to the controller * adds unencrypted password and password_confirmation to the controller test * adds encrypted password_digest to the fixture
* Add GeneratedAttribute#column_name to get the name of the column in theRafael Mendonça França2012-12-101-1/+1
| | | | database
* Extract a attributes_names method to avoid duplicationRafael Mendonça França2012-12-101-0/+7
|
* Remove observers and sweepersRafael Mendonça França2012-11-281-2/+2
| | | | | | | | They was extracted from a plugin. See https://github.com/rails/rails-observers [Rafael Mendonça França + Steve Klabnik]
* Use Ruby 1.9 Hash syntax in railtiesRobin Dupret2012-10-141-4/+4
|
* reduce number of StringsAkira Matsuda2012-06-061-1/+1
|
* Make method name consistent with existing methodsAndrew White2012-06-061-3/+3
|
* Fixed the application_controller require_dependency path generated by the ↵Fred Wu2012-06-061-4/+5
| | | | app generator
* Fix generators to help with ambiguous `ApplicationController` issuePiotr Sarnacki2012-05-201-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In development mode, dependencies are loaded dynamically at runtime, using `const_missing`. Because of that, when one of the constants is already loaded and `const_missing` is not triggered, user can end up with unexpected results. Given such file in an Engine: ```ruby module Blog class PostsController < ApplicationController end end ``` If you load it first, before loading any application files, it will correctly load `Blog::ApplicationController`, because second line will hit `const_missing`. However if you load `ApplicationController` first, the constant will be loaded already, `const_missing` hook will not be fired and in result `PostsController` will inherit from `ApplicationController` instead of `Blog::ApplicationController`. Since it can't be fixed in `AS::Dependencies`, the easiest fix is to just explicitly load application controller. closes #6413
* Don't indent blank lines in named base generatorsAlexey Vakhov2012-04-251-1/+1
|
* Updated/changed useless tr/gsubsJurriaan Pruis2012-04-031-1/+1
|
* Remove key_value helper now that master is 1.9 only and we always useRafael Mendonça França2012-03-131-5/+0
| | | | the 1.9 hash syntax in the generators.
* Tidy up migration types.José Valim2011-12-241-1/+1
|