-
Notifications
You must be signed in to change notification settings - Fork 21.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29916 from lugray/stop_generating_application_record
Stop creating ApplicationRecord on model generation
- Loading branch information
Showing
10 changed files
with
66 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...ord/lib/rails/generators/active_record/application_record/application_record_generator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails/generators/active_record" | ||
|
||
module ActiveRecord | ||
module Generators # :nodoc: | ||
class ApplicationRecordGenerator < ::Rails::Generators::Base # :nodoc: | ||
source_root File.expand_path("templates", __dir__) | ||
|
||
# FIXME: Change this file to a symlink once RubyGems 2.5.0 is required. | ||
def create_application_record | ||
template "application_record.rb", application_record_file_name | ||
end | ||
|
||
private | ||
|
||
def application_record_file_name | ||
@application_record_file_name ||= if namespaced? | ||
"app/models/#{namespaced_path}/application_record.rb" | ||
else | ||
"app/models/application_record.rb" | ||
end | ||
end | ||
end | ||
end | ||
end |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
railties/lib/rails/generators/rails/application_record/application_record_generator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
module Rails | ||
module Generators | ||
class ApplicationRecordGenerator < Base # :nodoc: | ||
hook_for :orm, required: true, desc: "ORM to be invoked" | ||
end | ||
end | ||
end |
14 changes: 14 additions & 0 deletions
14
railties/test/generators/application_record_generator_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require "generators/generators_test_helper" | ||
require "rails/generators/rails/application_record/application_record_generator" | ||
|
||
class ApplicationRecordGeneratorTest < Rails::Generators::TestCase | ||
include GeneratorsTestHelper | ||
|
||
def test_application_record_skeleton_is_created | ||
run_generator | ||
assert_file "app/models/application_record.rb" do |record| | ||
assert_match(/class ApplicationRecord < ActiveRecord::Base/, record) | ||
assert_match(/self\.abstract_class = true/, record) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters