title: Rails - generate a Scaffold within a Namespace
body: <p>I have an early stage project that I am trying to namespace before organization becomes a problem, following the most clear and up to date <a href="http://blog.makandra.com/2014/12/organizing-large-rails-projects-with-namespaces/" rel="nofollow">post</a> I can find regarding namespacing.</p>
  
  <p>But it doesn't work as magically as I'd hoped. How do I generate a Scaffold within a Namespace that is functional? I believe this is an issue of plurality vs. singularity.</p>
  
  <p>Example:</p>
  
  <pre><code>words
    languages
    definitions
  
  users
  </code></pre>
  
  <p>Generate:</p>
  
  <pre><code>rails g scaffold Words/Language name:string
  rails g scaffold Words/Definition name:string
  rails g scaffold Word name:string language:references definition:references user:references
  </code></pre>
  
  <p>After the above, there is an exception for <code>word.language</code> but not <code>word.user</code>:</p>
  
  <pre><code>irb(main)&gt; word = Word.find(1)
    Word Load (0.3ms)  SELECT  "words".* FROM "words" WHERE "words"."id" = ? LIMIT 1  [["id", 1]]
  =&gt; #&lt;Word id: 1, name: "Hello", language_id: 1, definition_id: 1, user_id: 1&gt;
  
  irb(main)&gt; word.user
    User Load (0.7ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1  [["id", 1]]
  =&gt; #&lt;User id: 1, name: "admin"&gt;
  
  irb(main)&gt; word.language
  NameError: uninitialized constant Word::Language
  </code></pre>
  
  <p>Rails generates two models, both <code>word.rb</code> and <code>words.rb</code>:</p>
  
  <p>app/models/word.rb</p>
  
  <pre><code>class Word &lt; ActiveRecord::Base
    belongs_to :language
    belongs_to :definition
    belongs_to :user
  end
  </code></pre>
  
  <p>app/models/words.rb</p>
  
  <pre><code>module Words
    def self.table_name_prefix
      'words_'
    end
  end
  </code></pre>
  
  <p>How do I combat this issue of singular vs. plural with namespaced generated scaffolds?</p>