title: Undefined method 'devise' when including User model outside Rails
body: <p>I am developing an application that consists in two parts: A ruby command line application and a Rails application for the front-end.</p>
  
  <p>I've been using ActiveRecord and the Rails models in the Ruby application by including them individually the following way:</p>
  
  <pre><code>Dir[File.dirname(__FILE__) + '/../../RailsApp/app/models/*.rb'].each do |file|
    filename = File.basename(file, File.extname(file))
    require_relative "../../RailsApp/app/models/" + filename
  end
  </code></pre>
  
  <p>And by manually mantaining two nearly identical Gemfile files for dependencies (an approach that I think is not the best)</p>
  
  <p>Yesterday I added Devise to the Rails application, and now when the ruby app tries to include the user model, the message <code>undefined method devise for class &lt;xxxxx&gt;</code> appears.</p>
  
  <p>I added the devise gem in my ruby app's Gemfile, but the error continues. If I understand correctly, Devise is a Rails Engine, which is why it's not being loaded just by requiring the gem.</p>
  
  <p>I read that a better approach to include Rails models inside another application is by requiring the <code>environment.rb</code> file, but when I tried that, I got an error with ActionMailer:</p>
  
  <pre><code>undefined method `action_mailer' for #&lt;Rails::Application::Configuration:0xbbb54bc&gt;
  </code></pre>
  
  <p>How can I solve the issue with devise? Is there a better way to include Rails models inside another application than the one I'm currently using to avoid mantaining two gemfiles ? Thanks</p>