public
Description: response for lets you decorate your actions respond_to blocks
Homepage: http://blog.ardes.com/response_for
Clone URL: git://github.com/ianwhite/response_for.git
Click here to lend your support to: response_for and make a donation at www.pledgie.com !
Updated README
ianwhite (author)
Sat Sep 13 20:48:02 -0700 2008
commit  7ce71c62e7b6304b84a9ba813b17c43bffdad73d
tree    0e6c4d48caf1be3ee73fcad2faae99f5ff466c43
parent  9dc94651a1ca42721e95af36728cdf8366156eca
...
12
13
14
15
16
17
18
19
20
 
 
21
22
23
24
25
26
27
28
29
30
 
31
32
33
34
35
 
 
36
37
38
39
40
41
42
43
44
...
53
54
55
 
 
 
 
 
 
...
12
13
14
 
 
 
 
 
 
15
16
17
18
19
20
21
22
 
 
 
 
23
24
25
26
 
 
27
28
29
30
31
32
 
 
33
34
35
...
44
45
46
47
48
49
50
51
52
0
@@ -12,33 +12,24 @@ As of version 0.2.0, response_for's functionality can be summed up in one senten
0
 
0
 "response_for allows you to specify default responses for any action (or before filter) that doesn't render or redirect"
0
 
0
-== Version 0.1
0
-
0
-Versions prior to 0.2 are tagged with 0.1.
0
-
0
-There is a branch for rails 2.0 users on this release.  If you are using rails 2.0, then you want the 0.1-stable-rails2.0 branch.  If you are
0
-using rails >= 2.1 then use the 0.1-stable branch
0
+Actions typically do two things - interact with models, and provide a repsonse.  The above simple idea allows you to decouple these
0
+two functions (where appropriate), which means abstraction of common patterns becomes possible.
0
 
0
 === Example
0
 
0
   class FooController < ApplicationController
0
     def index
0
       @foos = Foo.find(:all)
0
-    end
0
-    
0
-    def show
0
-      @foo = Foo.find(params[:id])
0
+      # default response - render html
0
     end
0
   end
0
   
0
-  # this controller needs to respond_to fbml on index, and
0
-  # js, html and xml (templates) on index and show
0
+  # this controller needs to respond_to fbml on index. 
0
+  # Using response_for, we don't need to repeat '@foos = Foo.find(1)'
0
   class SpecialFooController < FooController
0
     response_for :index do |format|
0
       format.fbml { render :inline => turn_into_facebook(@foos) }
0
     end
0
-    
0
-    response_for :index, :show, :types => [:html, :xml, :js]
0
   end
0
 
0
 === Specs and Coverage
0
@@ -53,3 +44,9 @@ RSpec is used for testing, so the tests are in <tt>spec/</tt> rather than
0
 
0
 garlic (at http://github.com/ianwhite/garlic) is used for CI.  To run the CI suite have a look at
0
 garlic_example.rb
0
+
0
+== Previous Versions: 0.1
0
+
0
+There is a branch for rails 2.0 users on this release.  If you are using rails 2.0, then you want the 0.1-stable-rails2.0 branch.  If you are
0
+using rails >= 2.1 then use the 0.1-stable branch
0
+

Comments