Method: Exposure::Responding::ClassMethods#response_for
- Defined in:
- lib/exposure/behaviors/responding.rb
#response_for(*actions, &block) ⇒ Object
response_for :create, :on => :success, :is => { proc } response_for :show, :formats => [:html] do
@resource.activated ? render('show') : render('next_steps')
end response_for :new, :is => :new_foo_built
valid action names are
:index :show :new :create :edit :update :destroy
valid options are
:on (optional)
:success, :failure, :any
default is :any
:is (option if block given)
can be a Proc or method name as symbol.
:formats
array of formats as symbols.
defaults to [:html]
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/exposure/behaviors/responding.rb', line 26 def response_for(*actions, &block) = actions. [:is] ||= block formats = [:formats] || [:html, :xml, :json] case [:on] when NilClass, :any build_custom_response(actions, :success, formats, [:is]) build_custom_response(actions, :failure, formats, [:is]) when :success build_custom_response(actions, :success, formats, [:is]) when :failure build_custom_response(actions, :failure, formats, [:is]) end end |