Sha256: 4a445d675e369944023569a19b0555f16b8ea780f3ca8d0aa8670632fff22509
Contents?: true
Size: 791 Bytes
Versions: 3
Compression:
Stored size: 791 Bytes
Contents
module Responders # Responder to accept callable objects as the redirect location. # Useful when you want to use the <tt>respond_with</tt> method with # a route that requires persisted objects, but the validation may fail. # # class ThingsController < ApplicationController # responders :location, :flash # respond_to :html # # def create # @thing = Things.create(params[:thing]) # respond_with @thing, location: -> { thing_path(@thing) } # end # end # module LocationResponder def initialize(controller, resources, options = {}) super if options[:location].respond_to?(:call) location = options.delete(:location) options[:location] = location.call unless has_errors? end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
responders-1.1.2 | lib/responders/location_responder.rb |
responders-1.1.1 | lib/responders/location_responder.rb |
responders-1.1.0 | lib/responders/location_responder.rb |