title: Extending the functionality of a model in a mounted rails engine
body: <p><strong>UPDATE 3:</strong></p>
  
  <p>This solution seems ugly but I moved the decorator back to the decorators directory and then just added this to my application controller: </p>
  
  <pre><code>require './app/decorators/models/monologue/post_decorator.rb'
  include ExtendPost
  require './app/decorators/controllers/monologue/admin/posts_controller_decorator.rb'
  include ExtendAdminPostsController
  </code></pre>
  
  <p>Thoughts for how to do this properly?  Thanks. </p>
  
  <p>But at least this works.  </p>
  
  <p><strong>UPDATE 2:</strong></p>
  
  <p>Well the following worked, but could someone please explain how to put this code in the "right" place and not where I stuck it:</p>
  
  <p>In my application_controller.rb in my main_app, I now have: </p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base 
  
  end
  
  Monologue::PostsRevision.class_eval do
     validates :title, :length =&gt; {:maximum =&gt; 25} 
  end
  </code></pre>
  
  <p>This works properly, but is in a bad location from an organizational / code readability standpoint.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I also tried something different based on the SO answer <a href="https://stackoverflow.com/a/9806113/1661110">here</a> and ended up with this code, which also did not work:</p>
  
  <p>In app/models/post_revision.rb (again, in main_app's app folder)</p>
  
  <pre><code>require Monologue::PostRevisions::Engine.config.root + 'app' + 'models' + 'page'
  class PostRevision
      validates :title, :length =&gt; {:maximum =&gt; 25} 
  end
  </code></pre>
  
  <p>This did not work either. </p>
  
  <p>When attempting to modify the functionality of a mounted engine in Rails 3 using decorators and the class_eval method, are the decorators supposed to go in the app folder in your main_app or in the app folder in your engine?  </p>
  
  <p>I am attempting to modify some of the models in an engine called Monologue that I got <a href="https://github.com/jipiboily/monologue" rel="nofollow noreferrer">here</a>.  I found a good explanation of how to do that on the site of a different product (Refinery) <a href="http://refinerycms.com/guides/extending-controllers-with-decorators" rel="nofollow noreferrer">here</a>.  And I also followed the instructions at this <a href="http://edgeguides.rubyonrails.org/engines.html#improving-engine-functionality" rel="nofollow noreferrer">Rails Guide</a>.</p>
  
  <p>So the code I ended up with was: </p>
  
  <p>In lib/monologue/engine.rb (is this supposed to be in the lib folder in the main app or the engine?  I put it in the lib folder in my main_app):  </p>
  
  <pre><code>module Monologue
      class Engine &lt; ::Rails::Engine
          isolate_namespace Monologue
  
          config.to_prepare do
              Dir.glob(Rails.root + "app/decorators/**/*_decorator*.rb").each do |c|
                  require_dependency(c)
              end
          end
     end
  end  
  </code></pre>
  
  <p>And in app/decorators/monologue/posts_revisions_decorator.rb (and again, I put this in the app folder in the main_app, not the Monologue engine app folder):</p>
  
  <pre><code>Monologue::PostsRevision.class_eval do
     validates :title, :length =&gt; {:maximum =&gt; 25} 
  end
  </code></pre>
  
  <p>But this does not work.  The additional validation does nothing.  </p>
  
  <p>If this is because it is supposed to go within the folders in the Monologue mounted engine and not the main_app, than I don't know how to do that since those files are not in my main_app directory.  </p>
  
  <p>Thoughts? Thanks. </p>