Search code examples
ruby-on-railspartial-viewsrenderpartial

render a view from another controller


I'm trying to render one view (index) from one controller to the view of another controller. index needs to calculate some values in the controller and render the view.

How do I do this?

example: in products/list I have

<%= render :partial=>"admin/index" %>

and in admin_controller:

def index
   @member = something
end

looks like the code in admin/controller never gets executed.

Thank you!


Solution

  • Render will just render the view, it won't run the action associated with it.

    You have to copy this:

       @member = something
    

    to your products/list action.