Skip to content

Commit

Permalink
Add app/models/concerns and app/controllers/concerns to the default d…
Browse files Browse the repository at this point in the history
…irectory structure and load path
  • Loading branch information
dhh committed Dec 18, 2012
1 parent dcb318e commit f6bbc3f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions railties/CHANGELOG.md
@@ -1,5 +1,9 @@
## Rails 4.0.0 (unreleased) ##

* Add app/models/concerns and app/controllers/concerns to the default directory structure and load path *DHH*

See http://37signals.com/svn/posts/3372-put-chubby-models-on-a-diet-with-concerns for usage instructions.

* The `public/index.html` is no longer generated for new projects.
Page is replaced by internal `welcome_controller` inside of railties.

Expand Down
9 changes: 9 additions & 0 deletions railties/lib/rails/engine/configuration.rb
Expand Up @@ -38,26 +38,35 @@ def generators #:nodoc:
def paths
@paths ||= begin
paths = Rails::Paths::Root.new(@root)

paths.add "app", eager_load: true, glob: "*"
paths.add "app/assets", glob: "*"
paths.add "app/controllers", eager_load: true
paths.add "app/helpers", eager_load: true
paths.add "app/models", eager_load: true
paths.add "app/mailers", eager_load: true
paths.add "app/views"

paths.add "app/controllers/concerns", eager_load: true
paths.add "app/models/concerns", eager_load: true

paths.add "lib", load_path: true
paths.add "lib/assets", glob: "*"
paths.add "lib/tasks", glob: "**/*.rake"

paths.add "config"
paths.add "config/environments", glob: "#{Rails.env}.rb"
paths.add "config/initializers", glob: "**/*.rb"
paths.add "config/locales", glob: "*.{rb,yml}"
paths.add "config/routes.rb"

paths.add "db"
paths.add "db/migrate"
paths.add "db/seeds.rb"

paths.add "vendor", load_path: true
paths.add "vendor/assets", glob: "*"

paths
end
end
Expand Down
4 changes: 4 additions & 0 deletions railties/lib/rails/generators/rails/app/app_generator.rb
Expand Up @@ -55,8 +55,12 @@ def gitignore

def app
directory 'app'

keep_file 'app/mailers'
keep_file 'app/models'

keep_file 'app/controllers/concerns'
keep_file 'app/models/concerns'
end

def config
Expand Down

8 comments on commit f6bbc3f

@kenn
Copy link
Contributor

@kenn kenn commented on f6bbc3f Dec 19, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I've been having app/models/traits to put together ActiveSupport::Concern mixins and now it's official. Great stuff!

@timothyklim
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@naveed-ahmad
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

@mikdiet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you think, app/models/concerns will be appropriate for storing association extension modules and custom validation classes? Same question for filter class for controllers.

@boostbob
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice places to hold Fooable.

@hulkfu
Copy link

@hulkfu hulkfu commented on f6bbc3f Sep 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slice up chubby models:+1:

@awais545
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@khanhpham1990
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool (y)

Please sign in to comment.