I think I’m approaching this the wrong way, which is why I can’t seem to figure out an easy solution. I’m relatively new to Rails, so bear with me.
I have a layout, “store,” that contains all of the common visual elements for the other controllers. In this layout, I need to dynamically create the sidebar with data from two models, Product and ProductFamily. I want it to output like so:
Product Family
---- Product1
---- Product2
And continue on through all relevant records.
I just can’t figure out where to start writing the logic for this. Does it go in the layout? In a controller?
Please, point me in the right direction!
It’s not “logic” in the sense we use it when saying that you should keep logic out of the views. It’s just a simple iteration for the purposes of display, so it would go in the view. You’d pass in the product line and do something along the lines of:
Add all the styling and links you want.