Skip to content
Newer
Older
100644 325 lines (300 sloc) 10.6 KB
ddfc072 Added AbstractController::Collector.
José Valim and Mikel Lindsaar authored Jan 23, 2010
1 require 'abstract_controller/collector'
e5ab4b0 @jeremy Convert to class_attribute
jeremy authored Jan 31, 2010
2 require 'active_support/core_ext/class/attribute'
a9f3c9d @sikachu Using Object#in? and Object#either? in various places
sikachu authored Apr 11, 2011
3 require 'active_support/core_ext/object/inclusion'
ddfc072 Added AbstractController::Collector.
José Valim and Mikel Lindsaar authored Jan 23, 2010
4
1c16649 @dhh Added better support for using the same actions to output for differe…
dhh authored Mar 11, 2006
5 module ActionController #:nodoc:
c59456a @joliss removed :nodoc: from ActionController::MimeResponds
joliss authored Apr 8, 2011
6 module MimeResponds
3e8ba61 @josevalim Refactor even more Responder. Move mime negotiation to request and ad…
josevalim authored Jul 28, 2009
7 extend ActiveSupport::Concern
8
944b4d5 @josevalim Add missing dependency.
josevalim authored Apr 18, 2011
9 include ActionController::ImplicitRender
10
3e8ba61 @josevalim Refactor even more Responder. Move mime negotiation to request and ad…
josevalim authored Jul 28, 2009
11 included do
e5ab4b0 @jeremy Convert to class_attribute
jeremy authored Feb 1, 2010
12 class_attribute :responder, :mimes_for_respond_to
2e37eff @josevalim Unify class_inheritable_accessor and extlib_inheritable_accessor and …
josevalim authored Oct 17, 2009
13 self.responder = ActionController::Responder
fa0cf66 @josevalim Add a couple more tests to respond_with.
josevalim authored Jul 29, 2009
14 clear_respond_to
3e8ba61 @josevalim Refactor even more Responder. Move mime negotiation to request and ad…
josevalim authored Jul 28, 2009
15 end
16
17 module ClassMethods
79f9fcd @wincent doc: cleanup respond_to documentation
wincent authored Jul 26, 2010
18 # Defines mime types that are rendered by default when invoking
19 # <tt>respond_with</tt>.
3e8ba61 @josevalim Refactor even more Responder. Move mime negotiation to request and ad…
josevalim authored Jul 28, 2009
20 #
21 # Examples:
22 #
23 # respond_to :html, :xml, :json
24 #
79f9fcd @wincent doc: cleanup respond_to documentation
wincent authored Jul 26, 2010
25 # Specifies that all actions in the controller respond to requests
26 # for <tt>:html</tt>, <tt>:xml</tt> and <tt>:json</tt>.
3e8ba61 @josevalim Refactor even more Responder. Move mime negotiation to request and ad…
josevalim authored Jul 28, 2009
27 #
79f9fcd @wincent doc: cleanup respond_to documentation
wincent authored Jul 26, 2010
28 # To specify on per-action basis, use <tt>:only</tt> and
29 # <tt>:except</tt> with an array of actions or a single action:
3e8ba61 @josevalim Refactor even more Responder. Move mime negotiation to request and ad…
josevalim authored Jul 28, 2009
30 #
31 # respond_to :html
32 # respond_to :xml, :json, :except => [ :edit ]
33 #
79f9fcd @wincent doc: cleanup respond_to documentation
wincent authored Jul 26, 2010
34 # This specifies that all actions respond to <tt>:html</tt>
35 # and all actions except <tt>:edit</tt> respond to <tt>:xml</tt> and
36 # <tt>:json</tt>.
3e8ba61 @josevalim Refactor even more Responder. Move mime negotiation to request and ad…
josevalim authored Jul 28, 2009
37 #
5850f16 @fxn removes the RJS template handler
fxn authored Mar 25, 2011
38 # respond_to :json, :only => :create
3e8ba61 @josevalim Refactor even more Responder. Move mime negotiation to request and ad…
josevalim authored Jul 28, 2009
39 #
79f9fcd @wincent doc: cleanup respond_to documentation
wincent authored Jul 26, 2010
40 # This specifies that the <tt>:create</tt> action and no other responds
5850f16 @fxn removes the RJS template handler
fxn authored Mar 25, 2011
41 # to <tt>:json</tt>.
3e8ba61 @josevalim Refactor even more Responder. Move mime negotiation to request and ad…
josevalim authored Jul 28, 2009
42 def respond_to(*mimes)
43 options = mimes.extract_options!
44
50d262f @avakhov Support symbol and string actions in AC#respond_to options
avakhov authored Oct 11, 2011
45 only_actions = Array(options.delete(:only)).map(&:to_s)
46 except_actions = Array(options.delete(:except)).map(&:to_s)
3e8ba61 @josevalim Refactor even more Responder. Move mime negotiation to request and ad…
josevalim authored Jul 28, 2009
47
e5ab4b0 @jeremy Convert to class_attribute
jeremy authored Feb 1, 2010
48 new = mimes_for_respond_to.dup
3e8ba61 @josevalim Refactor even more Responder. Move mime negotiation to request and ad…
josevalim authored Jul 28, 2009
49 mimes.each do |mime|
50 mime = mime.to_sym
e5ab4b0 @jeremy Convert to class_attribute
jeremy authored Feb 1, 2010
51 new[mime] = {}
52 new[mime][:only] = only_actions unless only_actions.empty?
53 new[mime][:except] = except_actions unless except_actions.empty?
3e8ba61 @josevalim Refactor even more Responder. Move mime negotiation to request and ad…
josevalim authored Jul 28, 2009
54 end
e5ab4b0 @jeremy Convert to class_attribute
jeremy authored Feb 1, 2010
55 self.mimes_for_respond_to = new.freeze
3e8ba61 @josevalim Refactor even more Responder. Move mime negotiation to request and ad…
josevalim authored Jul 28, 2009
56 end
57
79f9fcd @wincent doc: cleanup respond_to documentation
wincent authored Jul 26, 2010
58 # Clear all mime types in <tt>respond_to</tt>.
3e8ba61 @josevalim Refactor even more Responder. Move mime negotiation to request and ad…
josevalim authored Jul 28, 2009
59 #
fa0cf66 @josevalim Add a couple more tests to respond_with.
josevalim authored Jul 29, 2009
60 def clear_respond_to
e5ab4b0 @jeremy Convert to class_attribute
jeremy authored Feb 1, 2010
61 self.mimes_for_respond_to = ActiveSupport::OrderedHash.new.freeze
3e8ba61 @josevalim Refactor even more Responder. Move mime negotiation to request and ad…
josevalim authored Jul 28, 2009
62 end
63 end
3f445b3 @josevalim Refactor Responder to only calculate available mime types. Those are …
josevalim authored Jul 28, 2009
64
01f032f Added responds_to to new base.
Yehuda Katz + Carl Lerche authored May 20, 2009
65 # Without web-service support, an action which collects the data for displaying a list of people
66 # might look something like this:
67 #
68 # def index
1a6c4c8 @willcannings Correct deprecated AR usage in ActionController::MimeResponds documen…
willcannings authored Dec 19, 2010
69 # @people = Person.all
01f032f Added responds_to to new base.
Yehuda Katz + Carl Lerche authored May 20, 2009
70 # end
71 #
72 # Here's the same action, with web-service support baked in:
73 #
74 # def index
1a6c4c8 @willcannings Correct deprecated AR usage in ActionController::MimeResponds documen…
willcannings authored Dec 19, 2010
75 # @people = Person.all
01f032f Added responds_to to new base.
Yehuda Katz + Carl Lerche authored May 20, 2009
76 #
77 # respond_to do |format|
78 # format.html
79 # format.xml { render :xml => @people.to_xml }
80 # end
81 # end
82 #
83 # What that says is, "if the client wants HTML in response to this action, just respond as we
84 # would have before, but if the client wants XML, return them the list of people in XML format."
85 # (Rails determines the desired response format from the HTTP Accept header submitted by the client.)
86 #
87 # Supposing you have an action that adds a new person, optionally creating their company
88 # (by name) if it does not already exist, without web-services, it might look like this:
89 #
90 # def create
91 # @company = Company.find_or_create_by_name(params[:company][:name])
92 # @person = @company.people.create(params[:person])
93 #
94 # redirect_to(person_list_url)
95 # end
96 #
97 # Here's the same action, with web-service support baked in:
98 #
99 # def create
100 # company = params[:person].delete(:company)
101 # @company = Company.find_or_create_by_name(company[:name])
102 # @person = @company.people.create(params[:person])
103 #
104 # respond_to do |format|
105 # format.html { redirect_to(person_list_url) }
106 # format.js
107 # format.xml { render :xml => @person.to_xml(:include => @company) }
108 # end
109 # end
110 #
5850f16 @fxn removes the RJS template handler
fxn authored Mar 25, 2011
111 # If the client wants HTML, we just redirect them back to the person list. If they want JavaScript,
112 # then it is an Ajax request and we render the JavaScript template associated with this action.
01f032f Added responds_to to new base.
Yehuda Katz + Carl Lerche authored May 20, 2009
113 # Lastly, if the client wants XML, we render the created person as XML, but with a twist: we also
114 # include the person's company in the rendered XML, so you get something like this:
115 #
116 # <person>
117 # <id>...</id>
118 # ...
119 # <company>
120 # <id>...</id>
121 # <name>...</name>
122 # ...
123 # </company>
124 # </person>
125 #
126 # Note, however, the extra bit at the top of that action:
127 #
128 # company = params[:person].delete(:company)
129 # @company = Company.find_or_create_by_name(company[:name])
130 #
131 # This is because the incoming XML document (if a web-service request is in process) can only contain a
132 # single root-node. So, we have to rearrange things so that the request looks like this (url-encoded):
133 #
134 # person[name]=...&person[company][name]=...&...
135 #
136 # And, like this (xml-encoded):
137 #
138 # <person>
139 # <name>...</name>
140 # <company>
141 # <name>...</name>
142 # </company>
143 # </person>
144 #
145 # In other words, we make the request so that it operates on a single entity's person. Then, in the action,
146 # we extract the company data from the request, find or create the company, and then create the new person
147 # with the remaining data.
148 #
149 # Note that you can define your own XML parameter parser which would allow you to describe multiple entities
150 # in a single request (i.e., by wrapping them all in a single root node), but if you just go with the flow
151 # and accept Rails' defaults, life will be much easier.
152 #
153 # If you need to use a MIME type which isn't supported by default, you can register your own handlers in
7e075e6 Fixed many references to the old config/environment.rb and Rails::Ini…
Benjamin Quorning authored Jul 9, 2010
154 # config/initializers/mime_types.rb as follows.
01f032f Added responds_to to new base.
Yehuda Katz + Carl Lerche authored May 20, 2009
155 #
156 # Mime::Type.register "image/jpg", :jpg
09de34c @josevalim Added respond_with.
josevalim authored Jul 29, 2009
157 #
158 # Respond to also allows you to specify a common block for different formats by using any:
159 #
160 # def index
1a6c4c8 @willcannings Correct deprecated AR usage in ActionController::MimeResponds documen…
willcannings authored Dec 19, 2010
161 # @people = Person.all
09de34c @josevalim Added respond_with.
josevalim authored Jul 29, 2009
162 #
163 # respond_to do |format|
164 # format.html
165 # format.any(:xml, :json) { render request.format.to_sym => @people }
166 # end
167 # end
168 #
169 # In the example above, if the format is xml, it will render:
170 #
171 # render :xml => @people
172 #
173 # Or if the format is json:
174 #
175 # render :json => @people
176 #
177 # Since this is a common pattern, you can use the class method respond_to
178 # with the respond_with method to have the same results:
179 #
180 # class PeopleController < ApplicationController
181 # respond_to :html, :xml, :json
182 #
183 # def index
1a6c4c8 @willcannings Correct deprecated AR usage in ActionController::MimeResponds documen…
willcannings authored Dec 19, 2010
184 # @people = Person.all
6ac56ac @vijaydev fix incorrect code example
vijaydev authored Nov 7, 2011
185 # respond_with(@people)
09de34c @josevalim Added respond_with.
josevalim authored Jul 29, 2009
186 # end
187 # end
188 #
189 # Be sure to check respond_with and respond_to documentation for more examples.
190 #
3f445b3 @josevalim Refactor Responder to only calculate available mime types. Those are …
josevalim authored Jul 28, 2009
191 def respond_to(*mimes, &block)
67b2d08 @josevalim Ensure that the proper accept header value is set during tests.
josevalim authored Jul 29, 2009
192 raise ArgumentError, "respond_to takes either types or a block, never both" if mimes.any? && block_given?
3f78de6 @josevalim Ensure that blocks are also handled inside the responder.
josevalim authored Aug 29, 2009
193
567ac65 @sikachu Fix override API response bug in respond_with
sikachu authored Feb 3, 2012
194 if collector = retrieve_collector_from_mimes(mimes, &block)
2bf2055 @josevalim Clean up a bit default_response handling and cache format negotiation.
josevalim authored Feb 4, 2012
195 response = collector.response
196 response ? response.call : default_render({})
3f78de6 @josevalim Ensure that blocks are also handled inside the responder.
josevalim authored Aug 29, 2009
197 end
09de34c @josevalim Added respond_with.
josevalim authored Jul 29, 2009
198 end
672941d @jeremy Introduce a default respond_to block for custom types. Closes #8174.
jeremy authored May 26, 2007
199
6e0ac74 @josevalim Renamed ActionController::Renderer to ActionController::Responder and…
josevalim authored Aug 8, 2009
200 # respond_with wraps a resource around a responder for default representation.
1fd65c8 @josevalim Encapsulate respond_with behavior in a presenter.
josevalim authored Aug 5, 2009
201 # First it invokes respond_to, if a response cannot be found (ie. no block
202 # for the request was given and template was not available), it instantiates
6e0ac74 @josevalim Renamed ActionController::Renderer to ActionController::Responder and…
josevalim authored Aug 8, 2009
203 # an ActionController::Responder with the controller and resource.
5b7e81e @josevalim Allow respond_with to deal with http verb accordingly.
josevalim authored Jul 31, 2009
204 #
1fd65c8 @josevalim Encapsulate respond_with behavior in a presenter.
josevalim authored Aug 5, 2009
205 # ==== Example
5b7e81e @josevalim Allow respond_with to deal with http verb accordingly.
josevalim authored Jul 31, 2009
206 #
1fd65c8 @josevalim Encapsulate respond_with behavior in a presenter.
josevalim authored Aug 5, 2009
207 # def index
208 # @users = User.all
209 # respond_with(@users)
09de34c @josevalim Added respond_with.
josevalim authored Jul 29, 2009
210 # end
211 #
1fd65c8 @josevalim Encapsulate respond_with behavior in a presenter.
josevalim authored Aug 5, 2009
212 # It also accepts a block to be given. It's used to overwrite a default
213 # response:
f59984c @josevalim Add nagivational behavior to respond_with.
josevalim authored Aug 1, 2009
214 #
aebbbc7 @willcannings Fix respond_with example code so it makes sense
willcannings authored Dec 19, 2010
215 # def create
216 # @user = User.new(params[:user])
1fd65c8 @josevalim Encapsulate respond_with behavior in a presenter.
josevalim authored Aug 5, 2009
217 # flash[:notice] = "User was successfully created." if @user.save
5b7e81e @josevalim Allow respond_with to deal with http verb accordingly.
josevalim authored Jul 31, 2009
218 #
1fd65c8 @josevalim Encapsulate respond_with behavior in a presenter.
josevalim authored Aug 5, 2009
219 # respond_with(@user) do |format|
220 # format.html { render }
221 # end
7034272 @josevalim Add destroyed? to ActiveRecord, include tests for polymorphic urls fo…
josevalim authored Aug 1, 2009
222 # end
223 #
6e0ac74 @josevalim Renamed ActionController::Renderer to ActionController::Responder and…
josevalim authored Aug 8, 2009
224 # All options given to respond_with are sent to the underlying responder,
225 # except for the option :responder itself. Since the responder interface
aed135d @josevalim Renamed presenter to renderer, added some documentation and defined i…
josevalim authored Aug 6, 2009
226 # is quite simple (it just needs to respond to call), you can even give
227 # a proc to it.
7034272 @josevalim Add destroyed? to ActiveRecord, include tests for polymorphic urls fo…
josevalim authored Aug 1, 2009
228 #
a64abdd @amaia Explain in the method doc that you need to call respond_to at the cla…
amaia authored Mar 31, 2011
229 # In order to use respond_with, first you need to declare the formats your
230 # controller responds to in the class level with a call to <tt>respond_to</tt>.
231 #
4f9047e @josevalim Ensure collections are not treated as nested resources.
josevalim authored Aug 13, 2009
232 def respond_with(*resources, &block)
d2e7c1b @josevalim Raise an error if respond_with is invoked and no format is declared.
josevalim authored Jan 10, 2010
233 raise "In order to use respond_with, first you need to declare the formats your " <<
e5ab4b0 @jeremy Convert to class_attribute
jeremy authored Feb 1, 2010
234 "controller responds to in the class level" if self.class.mimes_for_respond_to.empty?
d2e7c1b @josevalim Raise an error if respond_with is invoked and no format is declared.
josevalim authored Jan 10, 2010
235
567ac65 @sikachu Fix override API response bug in respond_with
sikachu authored Feb 3, 2012
236 if collector = retrieve_collector_from_mimes(&block)
b1667c7 @chriseppstein Correctly handle the case of an API response that returns a hash by t…
chriseppstein authored Nov 5, 2010
237 options = resources.size == 1 ? {} : resources.extract_options!
567ac65 @sikachu Fix override API response bug in respond_with
sikachu authored Feb 3, 2012
238
2bf2055 @josevalim Clean up a bit default_response handling and cache format negotiation.
josevalim authored Feb 4, 2012
239 if defined_response = collector.response
567ac65 @sikachu Fix override API response bug in respond_with
sikachu authored Feb 3, 2012
240 if action = options.delete(:action)
241 render :action => action
242 else
2bf2055 @josevalim Clean up a bit default_response handling and cache format negotiation.
josevalim authored Feb 4, 2012
243 defined_response.call
567ac65 @sikachu Fix override API response bug in respond_with
sikachu authored Feb 3, 2012
244 end
245 else
246 (options.delete(:responder) || self.class.responder).call(self, resources, options)
247 end
684a6b3 @josevalim Attempt to render the template inside the responder, so it can be use…
josevalim authored Aug 29, 2009
248 end
aed135d @josevalim Renamed presenter to renderer, added some documentation and defined i…
josevalim authored Aug 6, 2009
249 end
7a4a679 @josevalim Remove any resource logic from respond_to.
josevalim authored Jul 30, 2009
250
251 protected
252
09de34c @josevalim Added respond_with.
josevalim authored Jul 29, 2009
253 # Collect mimes declared in the class method respond_to valid for the
254 # current action.
255 #
256 def collect_mimes_from_class_level #:nodoc:
50d262f @avakhov Support symbol and string actions in AC#respond_to options
avakhov authored Oct 11, 2011
257 action = action_name.to_s
3e8ba61 @josevalim Refactor even more Responder. Move mime negotiation to request and ad…
josevalim authored Jul 28, 2009
258
e5ab4b0 @jeremy Convert to class_attribute
jeremy authored Feb 1, 2010
259 self.class.mimes_for_respond_to.keys.select do |mime|
260 config = self.class.mimes_for_respond_to[mime]
09de34c @josevalim Added respond_with.
josevalim authored Jul 29, 2009
261
262 if config[:except]
a9f3c9d @sikachu Using Object#in? and Object#either? in various places
sikachu authored Apr 10, 2011
263 !action.in?(config[:except])
09de34c @josevalim Added respond_with.
josevalim authored Jul 29, 2009
264 elsif config[:only]
a9f3c9d @sikachu Using Object#in? and Object#either? in various places
sikachu authored Apr 10, 2011
265 action.in?(config[:only])
09de34c @josevalim Added respond_with.
josevalim authored Jul 29, 2009
266 else
267 true
3e8ba61 @josevalim Refactor even more Responder. Move mime negotiation to request and ad…
josevalim authored Jul 28, 2009
268 end
269 end
09de34c @josevalim Added respond_with.
josevalim authored Jul 29, 2009
270 end
3e8ba61 @josevalim Refactor even more Responder. Move mime negotiation to request and ad…
josevalim authored Jul 28, 2009
271
3f78de6 @josevalim Ensure that blocks are also handled inside the responder.
josevalim authored Aug 29, 2009
272 # Collects mimes and return the response for the negotiated format. Returns
273 # nil if :not_acceptable was sent to the client.
684a6b3 @josevalim Attempt to render the template inside the responder, so it can be use…
josevalim authored Aug 29, 2009
274 #
567ac65 @sikachu Fix override API response bug in respond_with
sikachu authored Feb 3, 2012
275 def retrieve_collector_from_mimes(mimes=nil, &block) #:nodoc:
d2e7c1b @josevalim Raise an error if respond_with is invoked and no format is declared.
josevalim authored Jan 10, 2010
276 mimes ||= collect_mimes_from_class_level
2bf2055 @josevalim Clean up a bit default_response handling and cache format negotiation.
josevalim authored Feb 4, 2012
277 collector = Collector.new(mimes)
3f78de6 @josevalim Ensure that blocks are also handled inside the responder.
josevalim authored Aug 29, 2009
278 block.call(collector) if block_given?
2bf2055 @josevalim Clean up a bit default_response handling and cache format negotiation.
josevalim authored Feb 4, 2012
279 format = collector.negotiate_format(request)
684a6b3 @josevalim Attempt to render the template inside the responder, so it can be use…
josevalim authored Aug 29, 2009
280
2bf2055 @josevalim Clean up a bit default_response handling and cache format negotiation.
josevalim authored Feb 4, 2012
281 if format
f2c0a35 @josevalim Finish cleaning up rendering stack from views and move assigns evalua…
josevalim authored Mar 12, 2010
282 self.content_type ||= format.to_s
19433ce @spastorino format lookup for partials is derived from the format in which the te…
spastorino authored Feb 21, 2012
283 lookup_context.formats = [format.to_sym]
567ac65 @sikachu Fix override API response bug in respond_with
sikachu authored Feb 3, 2012
284 collector
684a6b3 @josevalim Attempt to render the template inside the responder, so it can be use…
josevalim authored Aug 29, 2009
285 else
286 head :not_acceptable
3f78de6 @josevalim Ensure that blocks are also handled inside the responder.
josevalim authored Aug 29, 2009
287 nil
684a6b3 @josevalim Attempt to render the template inside the responder, so it can be use…
josevalim authored Aug 29, 2009
288 end
289 end
290
6e0ac74 @josevalim Renamed ActionController::Renderer to ActionController::Responder and…
josevalim authored Aug 8, 2009
291 class Collector #:nodoc:
ddfc072 Added AbstractController::Collector.
José Valim and Mikel Lindsaar authored Jan 23, 2010
292 include AbstractController::Collector
2bf2055 @josevalim Clean up a bit default_response handling and cache format negotiation.
josevalim authored Feb 4, 2012
293 attr_accessor :order, :format
3f445b3 @josevalim Refactor Responder to only calculate available mime types. Those are …
josevalim authored Jul 28, 2009
294
2bf2055 @josevalim Clean up a bit default_response handling and cache format negotiation.
josevalim authored Feb 4, 2012
295 def initialize(mimes)
296 @order, @responses = [], {}
74049b5 @spastorino implicit self here
spastorino authored Nov 25, 2010
297 mimes.each { |mime| send(mime) }
7af12d0 @dhh Added synonym and custom type handling to respond_to [DHH]
dhh authored Mar 12, 2006
298 end
6480d49 @jamis Add MimeResponds::Responder#any for managing multiple types with iden…
jamis authored Mar 15, 2006
299
300 def any(*args, &block)
011e469 @lifo Make MimeResponds::Responder#any work without explicit types. Closes #…
lifo authored Mar 7, 2008
301 if args.any?
302 args.each { |type| send(type, &block) }
303 else
3e8ba61 @josevalim Refactor even more Responder. Move mime negotiation to request and ad…
josevalim authored Jul 28, 2009
304 custom(Mime::ALL, &block)
011e469 @lifo Make MimeResponds::Responder#any work without explicit types. Closes #…
lifo authored Mar 7, 2008
305 end
6dea52c @dhh Finish custom handling [DHH]
dhh authored Jun 2, 2006
306 end
7e280c3 @josevalim Remove Mime::ALL from Mime::SET.
josevalim authored Jul 29, 2009
307 alias :all :any
3f445b3 @josevalim Refactor Responder to only calculate available mime types. Those are …
josevalim authored Jul 28, 2009
308
309 def custom(mime_type, &block)
6e55916 @spastorino There's no need for ternary op here
spastorino authored Nov 22, 2010
310 mime_type = Mime::Type.lookup(mime_type.to_s) unless mime_type.is_a?(Mime::Type)
3f445b3 @josevalim Refactor Responder to only calculate available mime types. Those are …
josevalim authored Jul 28, 2009
311 @order << mime_type
312 @responses[mime_type] ||= block
6dc1288 @wycats Remove method missing use in respond_to
wycats authored Dec 26, 2008
313 end
672941d @jeremy Introduce a default respond_to block for custom types. Closes #8174.
jeremy authored May 26, 2007
314
2bf2055 @josevalim Clean up a bit default_response handling and cache format negotiation.
josevalim authored Feb 4, 2012
315 def response
316 @responses[format] || @responses[Mime::ALL]
317 end
318
319 def negotiate_format(request)
320 @format = request.negotiate_mime(order)
3f445b3 @josevalim Refactor Responder to only calculate available mime types. Those are …
josevalim authored Jul 28, 2009
321 end
1c16649 @dhh Added better support for using the same actions to output for differe…
dhh authored Mar 11, 2006
322 end
323 end
0ee1cb2 @jeremy Ruby 1.9 compat, consistent load paths
jeremy authored Oct 2, 2007
324 end
Something went wrong with that request. Please try again.