views:

101

answers:

5

I know this is odd. but I can't figure other ways to do what I need. I have a controller: report and a view: report. Also I have a view that acts as a dashboard where I can see several zones (partials). I need to add this report view to my dashboard but don't know how. This report view utilizes complex logic from controller and displays the results. How could I "stuck" the (logic+presentation) of exising view (report) into my partial, so I could use it on my dashboard??

Thank you. Valve.

A: 

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

+1  A: 

(I hope I'm understanding the problem, here...)

This part seemed significant:

This report view utilizes complex logic from controller

As a general rule, controllers should be simple. Really simple. The rule of thumb is "thin controller, fat model" (Rails Envy made some entertaining but useful screencasts on the subject)

What would happen if you created a new model (quite possibly not inheriting from ActiveRecord::Base) that encapsulated the logic you want to deliver into the partial? Then different controller/action combinations can deliver the information into your views as necessary/required.

Or have I completely missed the point (not impossible!)

Mike Woodhouse
A: 

Mike, you have not, actually. The problem is that I'm dealing with somebody else's code. (Actually, I'm dealing with redmine 0.7.1). I need to be able to add functionality from report view to 'my page' available widgets (those, droppable, you know). Please advise.

Valve.

Valentin Vasiliev
I'm not familiar with the app, I just Googled it, though and it looks interesting enough to take a further look.
Mike Woodhouse
A: 

If I'm not mistaken you can do a render_component, but this is completely frowned upon nowadays.

This is the easiest way to your problem though

ucron
A: 

I would suggest to refactor the code from the report controller (if this is the one that contains the "complex" logic) and put it into a wrapper class that can be used by the dashboard and report view.

Stevens