Skip to content

Commit

Permalink
Merge pull request rails#3289 from avakhov/p-respond_to-conditions
Browse files Browse the repository at this point in the history
Support symbol and string actions in AC#respond_to options
  • Loading branch information
josevalim committed Oct 11, 2011
2 parents 1735868 + 50d262f commit 7b84e36
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions actionpack/lib/action_controller/metal/mime_responds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ module ClassMethods
def respond_to(*mimes)
options = mimes.extract_options!

only_actions = Array(options.delete(:only))
except_actions = Array(options.delete(:except))
only_actions = Array(options.delete(:only)).map(&:to_s)
except_actions = Array(options.delete(:except)).map(&:to_s)

new = mimes_for_respond_to.dup
mimes.each do |mime|
Expand Down Expand Up @@ -245,7 +245,7 @@ def respond_with(*resources, &block)
# current action.
#
def collect_mimes_from_class_level #:nodoc:
action = action_name.to_sym
action = action_name.to_s

self.class.mimes_for_respond_to.keys.select do |mime|
config = self.class.mimes_for_respond_to[mime]
Expand Down
2 changes: 1 addition & 1 deletion actionpack/test/controller/mime_responds_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ def test_invalid_format
class RespondWithController < ActionController::Base
respond_to :html, :json
respond_to :xml, :except => :using_resource_with_block
respond_to :js, :only => [ :using_resource_with_block, :using_resource, :using_hash_resource ]
respond_to :js, :only => [ :using_resource_with_block, :using_resource, 'using_hash_resource' ]

def using_resource
respond_with(resource)
Expand Down

0 comments on commit 7b84e36

Please sign in to comment.