title: Rails sort posts by Category
body: <p>After doing my due diligence online and elsewhere, I'm still having trouble sorting my posts (view and controller) based on their category. </p>
  
  <p>I have three models: <code>Design</code>, <code>Category</code>, and <code>Type</code>.</p>
  
  <p>Design.rb</p>
  
  <pre><code>belongs_to :type
  </code></pre>
  
  <p>Category.rb</p>
  
  <pre><code>has_many :designs
  has_many :types, :order =&gt; "name"
  </code></pre>
  
  <p>Type.rb</p>
  
  <pre><code>belongs_to :category
  belongs_to :design
  </code></pre>
  
  <p>If something needs to be changed here, please shed light to that. </p>
  
  <p>After starting this search to find the answer to sort posts, I came across another problem that I'll ask in another question but will disclose here just in case. In the Command Line, if I search for a category, I get the category but also the warning:</p>
  
  <pre><code>DEPRECATION WARNING: The following options in your Category.has_many :types declaration are deprecated: :order. Please use a scope block instead.
  </code></pre>
  
  <p>and when I search for a Type I get this warning:</p>
  
  <pre><code>DEPRECATION WARNING: Using #scope without passing a callable object is deprecated. For example `scope :red, where(color: 'red')` should be changed to `scope :red, -&gt; { where(color: 'red') }`.
  </code></pre>
  
  <p>Anyway, in my current app, the categories are <code>men</code> and <code>women</code> and the types include <code>accessories, shirts, tops, jackets, etc</code> and so on. When a user created a design, they have a select to choose the type that has headings like this:</p>
  
  <pre><code>Men
    Accessories
    Jackets
    etc
  Women
    Accessories
    Dresses
    etc
  </code></pre>
  
  <p>In my view, I want the user to be able to sort the posts by men or women (Category) and also even further by <code>Type</code>, like <code>Women's Accessories</code> or <code>Men's Accessories</code></p>
  
  <p>Both Category and Type's can be found by either their ID or a string.</p>
  
  <p>If I can provide anything else to help, please let me know and I'll include as much as I can. Thanks.</p>