Is there a way to run the view inside a partial

I know this is weird. but i can't figure out other ways to do what i need. I have a controller: report and view: report. Also I have a view that acts like a panel where I see multiple zones (partial). I need to add this report to my dashboard but dont know how. This report view uses complex controller logic and displays the results. How could I "get stuck" (boolean + view) of the output view (report) in my partials so that I could use it in the dashboard?

Thank. Valve.

+1


source to share


4 answers


(I hope I understand the problem, here ...)

This part seemed significant:

This report view uses complex logic from a controller



Typically, controllers should be simple. Really simple. A rule of thumb is "thin controller, fat model" (Rails Envy has done some interesting but useful screencasts on the topic )

What happens if you create a new model (perhaps not inheriting from ActiveRecord :: Base) that encapsulates the logic you want to pass into a partial? Then different combinations of controllers / actions can deliver information to your views as needed / required.

Or am I completely missing the point (not impossible!)

+1


source


I had a similar problem a while ago when they deprecated render_controller. The only solution I have found is to use ajax passing the parameter to the page you want to load, layout traversal.



0


source


If I'm not mistaken, you can do render_component, but this is completely deprecated at the moment.

This is the easiest way for your problem though

0


source


I would suggest refactoring the code from the report controller (if it's one that contains "complex" logic) and putting it in a wrapper class that can be used by the dashboard and report view.

0


source







All Articles