New in Edge: Render Filters

Posted by Matthew Mon, 25 Jun 2007 13:48:00 GMT

We’re excited to announce a new feature in Edge that will make it much easier to use Streamlined’s default actions while still having control over what gets rendered afterwards. Render filters allow you to tack additional code onto the end of a default action.

Matthew demonstrated these filters in a very early form at the Streamlined tutorial at RailsConf last month. They have since become much more useful and flexible. By using these filters, we’ve been able to stop copying and pasting default actions into our controllers only to make a single small change. Now, we can make the small change declaratively without redefining the action.

For example, what if you prefer that Streamlined redirect back to the list view instead of the show view after updating a record? You would add this render filter to your controller:

render_filter :update, :success => Proc.new {
  redirect_to :action => 'list'
}

What this says is that the Streamlined’s default update action should redirect back to the list action on success. (Render paths can also be defined for failure.)

The contents of the Proc are called in the context of the controller action itself, allowing you to redirect, assign new instance vars, etc. (Pretty much anything you can do inside a controller action.)

More examples and documentation can be found on the wiki.

Posted in  | 2 comments | no trackbacks

Trackbacks: 0

Use the following link to trackback from your own site: http://streamlinedframework.org/articles/trackback/134

Comments: 2

Leave a response | RSS feed for this post

  1. # CN said 8 days later:

    Please update the link for the WIKI in this post… It links to the old address.

    Cheers

  2. # Jason Rudolph said 9 days later:

    Thanks, CN. The link is now updated to point to the new address.

Leave a response

Toggle website and email fields