Skip to content
Browse files

Merge branch 'fidothe-namespace-collision-warning' into build

  • Loading branch information...
jodosha committed May 20, 2016
2 parents 3205103 + ec8db6f commit f51d48642432f2c6e85063ca9abdcfcddd5e1759
Showing with 7 additions and 0 deletions.
  1. +7 −0 source/guides/actions/
@@ -54,6 +54,13 @@ The last bit is `Dashboard`, which is our controller.

The whole action name is `Web::Controllers::Dashboard::Index`.

<p class="warning">
You should avoid giving your action modules the same name as your application, e.g. avoid naminng a controller `Web` in an app named `Web`. If you have a controller name like `Web::Controllers::Web` then some code across your app will break with errors about constants not being found, for example in views which `include Web::Layout`. This is because Ruby starts constant lookup with the current module, so a constant like `Web::Layout` referenced by code in the `Web::Controllers::Web` or `Web::Controllers::Web::MyAction` module will be converted to `Web::Controllers::Web::Layout`, which can't be found and causes a constant lookup error.
<p class="warning">
If you absolutely must name a controller with the same name as your application, you'll need to explicitly set the namespace lookup for things which should be included from immediately under the app, not the controller by prefixing those names with `::`, e.g. change your views to include `::Web::Layout` instead of `include Web::Layout`, and using `include ::Web::Action` in your controllers.

### Action Module

Hanami philosophy emphasizes _composition over inheritance_ and avoids the [framework superclass antipattern](

0 comments on commit f51d486

Please sign in to comment.
You can’t perform that action at this time.