title: Rails 5.1+: namespaced models and default path generators
body: <p>I'm using namespaces on my models to organize a large project. However, when you namespace a model, the default url/path generators in Rails use that namespace in the routes:</p>
  
  <pre><code>module Workflows
    class Workflow &lt; ApplicationRecord
      # ...
    end
  end
  
  &lt;%= form_with model: @workflow, url: @workflow do |form| %&gt;
  # =&gt; produces URL: workflows_workflow_path(@workflow)
  </code></pre>
  
  <p>I've seen lots of SO posts about overriding the <code>model_name</code> but it doesn't do anything for me.  I've tried all of the following versions:</p>
  
  <pre><code>module Workflows
    class Workflow &lt; ApplicationRecord
      def self.model_name
        # Have tried all of the following as per various SO questions...
        ActiveModel::Name.new(Workflow)
        ActiveModel::Name.new(::Workflows::Workflow, nil, nil)
      end
    end
  end
  </code></pre>
  
  <p>When I check the model_name, it specifically says that the <code>route_key</code> is <code>workflows_workflow</code>, even with the ActiveModel name overrides in place.</p>
  
  <p>I'm running Rails 5.1 and Ruby 2.4.1.</p>
  
  <p>How do I force Rails to treat these namespaced models as non-namespaced?  The namespacing is just for developer organization, I don't need Rails to "do" anything with the namespacing.</p>