Here is my question. I basically have Controller A. What I want to do is display the index action of Controller B within the index view of Controller A.
I did this by making a new partial where I put my code snippet. I then rendered the correct partial and it gave me undefined variable errors. The only way I fixed it was by making an instance variable that included all of the instances of that model object. It works! But...is this the correct way to do it? Making an instance variable with all of the records seems that clumsy.
This is the index view of my Controller A. "Monthly_Challenges" is my Controller B.
<%= render "monthly_challenges/index" %>
<br>
Here is my partial. Note line 1, is that right?
<% @monthly_challenge = MonthlyChallenge.all %> #this seems not good
<p>
<strong>Name:</strong>
<%= @monthly_challenge.name %>
</p>
= render partial: "monthly_challenges/index", monthly_challenge: @monthly_challengethat you can use to include partials. That way you only have to initialize the variable at the first controller. Not sure if that's what you're looking for. You can use the variablemonthly_challengein the partial that way.