How to make several partials use the same model

advertisements

I am trying to make a page that separates users into different categories based on the sport they chose during signup. I am currently trying to do it with two different partials. The issue I am running into is that I can't have two separate partials use the same model. How would I do this?


Hm. Partials are just a way to split up html.erb code in multiple smaller files and possibly reusing them between various views.

If you want the separation in one view, and are new to rails, I would try it without partials until it works (maybe just for two categories).

Then, you can factor out the repeated code into partials and reuse them, and of course you can use all models there. Maybe you're just not aware of the possibility to pass parameters into partials? Like, if @feed_item was the variable set by the controller (or any other variable)

<%= render 'shared/feed_item_raw', feed_item: @feed_item %>

and then in the partial simply refer to it with feed_item