Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9953 (closed enhancement: fixed)

Opened 9 months ago

Last modified 9 months ago

[Patch] Add hook in perform_action to allow modifying the default render action

Reported by: cjheath Assigned to: core
Priority: normal Milestone: 2.x
Component: ActiveRecord Version: edge
Severity: normal Keywords:
Cc:

Description

If neither render nor redirect is called, the default is to call render for a template of the same name as the action. There is currently no way to add to the explicit actions (render and redirect). In the case where a multi-pane single-page app is having panes refreshed, each refresh is a logically separate RJS action, but currently, all must be called from a single render, which subverts this logical separation.

This ticket is for a patch that adds an add_default_render method to Controller::Base, which appends a passed block to @default_render_chain. If no render or redirect occurs, the blocks on this array get called in order until one returns true, and only if none do, the current default render applies.

In this way a plugin can define a method (in my case "refresh") which replaces the default render operation with a render :update that calls all the refresh blocks. That way each refresh block is properly isolated from the others.

This was discussed in rails core around 2007/09/25.

Attachments

default_render_patch.diff (3.8 kB) - added by cjheath on 10/23/07 01:58:51.

Change History

10/23/07 01:58:51 changed by cjheath

  • attachment default_render_patch.diff added.

10/23/07 02:03:13 changed by cjheath

Simplified patch uploaded. Now there is no @default_render_chain, just a default_render method that a plugin can override. perform_action calls default_render, which calls render.

10/25/07 06:38:05 changed by nzkoz

  • status changed from new to closed.
  • resolution set to fixed.

(In [8011]) Refactor the default rendering out to a method called default_render to provide a hook for plugin authors. Closes #9953 [cjheath]