0
@@ -6,7 +6,7 @@ response_for (see Ardes::ResponseFor::ClassMethods) allows you to decorate the r
0
As of version 0.2.0, response_for's functionality can be summed up in one sentence:
0
-
"response_for allows you to specify default responses for any action (or before filter) that doesn't render or redirect"0
+
<b>"response_for allows you to specify default responses for any action (or before filter) that doesn't render or redirect"</b>0
Actions typically do two things - interact with models, and render a response. The above simple idea allows you to decouple these
0
two functions (where appropriate), which means abstraction of common patterns becomes possible.
0
@@ -16,7 +16,6 @@ You should use 0.1-stable in your existing projects until you have runs your spe
0
If you want to know more about why I changed the API in 0.2 look at the bottom of this README
0
class FooController < ApplicationController
0
@@ -59,13 +58,40 @@ headaches, such as:
0
respond_to_without_response_for in any bail out code.
0
* Conceptually, overriding code declared in methods, with code declared at the class level, is weird. Here's an example
0
- class FooController < SuperclassController
0
- response_for :index # override Superclass's index respond_to
0
+ class FooController < SuperclassController
0
+ response_for :index # override Superclass's index respond_to
0
- respond_to # one might expect this to override the above, as its declared later - but it wont!
0
+ respond_to # one might expect this to override the above, as its declared later - but it wont!
0
+So, in 0.2 a much simpler idea is behind response_for - you can declare a default response for an action which will be performed
0
+if <b>that that action has not already performed a render or redirect</b>. This means that all of your bail out code written with
0
+respond_to will do what it's supposed to.
0
+If you're upgrading, you just need to convert any actions you want to override from this:
0
+ respond_to do |format|
0
+ format.xml { render :xml => @things }
0
+ response_for :index fo |format|
0
+ format.xml { render :xml => @things }
0
== Previous Versions: 0.1