Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<ol> <li><p>Probably this is the right way if you have 2-3 categories. If your system is going to grow, you'll surely want to make the implementation more flexible.</p></li> <li><p>Not sure what issues you expect with search. My best bet is that on the search results page you'll have items of different kinds, so you'll just need different partials to render them.</p></li> <li><p>As I said, adding support for different categories can be tedious with your current approach. I can suggest two things (not necessarily mutually exclusive):</p> <ul> <li>use a convention for associating category name with a layout (e.g. category 'electronics' is rendered via <code>electronics</code> layout). This way you'll be able to just <code>render :layout =&gt; @item.category</code>, and this code is adding-new-categories-proof</li> <li>as your system will grow and enhance, you might find it necessary to introduce a whole new model for your categories. Think of it now, maybe you'll want to do this right now.</li> </ul></li> <li><p>Polymorphic associations are a different thing. There should be two models for those, you currently have only one. See the <a href="http://guides.rubyonrails.org/association_basics.html" rel="nofollow noreferrer">Rails Guides, 2.9</a>.</p></li> </ol> <p>By the way, I'm not sure why you need the whole layout to differ for categories. If the overall look of your site is consistent, then it's probably more suitable to just have different partials for items of different categories.</p> <p>Regarding the urls, this question has been brought up numerous times (<a href="https://stackoverflow.com/questions/1049455/rails-routing-question-mapping-slugs-permalinks-directly-under-root">here</a>, and <a href="https://stackoverflow.com/questions/1252506/rails-slugs-in-url-using-record-title-instead-of-id">there</a>).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload