meteor meteor - 1 year ago 38
JSON Question

rails: use jbuilder template in various controller methods

Is it possible to reuse jbuilder-template in another controller method? In other words: how to explicitly say controller method to use concrete jbuilder-template?

Answer Source

From Rails guide.

Rendering an Action's Template from Another Controller.

What if you want to render a template from an entirely different controller from the one that contains the action code? You can also do that with render, which accepts the full path (relative to app/views) of the template to render. For example, if you're running code in an AdminProductsController that lives in app/controllers/admin, you can render the results of an action to a template in app/views/products this way

def my_action
  # some code here
  render "products/show"
end
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download