Problem with: "Getting Started with Engines" RailsGuide

In the getting started with engines tutorial there seem to be some inconsistencies with section 6.1.3 Implementing Decorator Pattern Using ActiveSupport::Concern.

First of all the tutorial steps (6.1.1, 6.1.2) and (6.1.3) seem to be exclusive, although this is never explicitly stated. Following the tutorial up to 6.1.3 and attempting to start a rails server via ‘rails s’ results in an error. When removing the code from steps 6.1.1 & 6.1.2 the rails server starts.

When completing the tutorial up to step 6.1 and then following step 6.1.3 there are still some problems: *

After the server is started trying to access the posts index or a posts page the page renders an “uninitialized constant Concerns::Models” error page on the first load and “uninitialized constant Blorgh::Concerns” errors thereafter.

The code for the Concern is labelled as Blorgh/lib/concerns/models/post when it should be Blorgh/lib/concerns/models/post.rb.

Since the concerns are placed in the lib folder they aren’t loaded. One workaround is to place the concern in the engine under app/models/blorgh/concerns/post.rb. Then the include however needs to be changed in MyApp to Blorgh::Concerns::Post. **

Also the engine’s actual post model is labelled as existing in: Blorgh/app/models/post.rb when it should be in Blorgh/app/models/blorgh/post.rb as that’s where it was previously created in the tutorial.

Furthermore the code in the post concern doesn’t take into account the “has_many :comments” and “class_name: Blorgh.author_class.to_s”/“Blorgh.author_class.find_or_create_by(name: author_name)” changes from previous steps.

The truncate(text) method requires ActionView::Helpers::TextHelper which the tutorial never mentions to include (this is also a problem for step 6.1.2)

There may be a better way to include the concerns in the engine other than putting it under models/blorgh/concerns/, like keeping it in lib/blorgh/concerns, but this doesn’t work out of the box obviously, or I’m missing something.


I have to thank you a lot. This helped me solving the issue I’m facing as a beginner following the docs. Please try to make a pull request on this in order to avoid other beginners to waste hours trying to figure out what they did wrong.