Permalink
Browse files

Add app/models/concerns and app/controllers/concerns to the default d…

…irectory structure and load path
  • Loading branch information...
1 parent dcb318e commit f6bbc3f582bfc16da3acc152c702b04102fcab81 @dhh dhh committed Dec 18, 2012
@@ -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.
@@ -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
@@ -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

8 comments on commit f6bbc3f

@kenn
Contributor
kenn commented on f6bbc3f Dec 19, 2012

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

@TimothyKlim

👍

@naveed-ahmad

Nice 👍

@Mik-die
Contributor

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

nice places to hold Fooable.

@astonfu

slice up chubby models👍

@awais545

👍

@khanhpham1990

Cool (y)

Please sign in to comment.