Sha256: e673ed6b99e8fafd64cce978d0ee01256e6bd329e1094ace6cd0b790fe0dbf6a

Contents?: true

Size: 941 Bytes

Versions: 22

Compression:

Stored size: 941 Bytes

Contents

module Responders
  # This responder modifies your current responder to redirect
  # to the collection page on POST/PUT/DELETE.
  module CollectionResponder
    protected

    # Returns the collection location for redirecting after POST/PUT/DELETE.
    # This method, converts the following resources array to the following:
    #
    #   [:admin, @post] #=> [:admin, :posts]
    #   [@user, @post]  #=> [@user, :posts]
    #
    # When these new arrays are given to redirect_to, it will generate the
    # proper URL pointing to the index action.
    #
    #   [:admin, @post] #=> admin_posts_url
    #   [@user, @post]  #=> user_posts_url(@user.to_param)
    #
    def navigation_location
      return options[:location] if options[:location]
      klass = resources.last.class

      if klass.respond_to?(:model_name)
        resources[0...-1] << klass.model_name.route_key.to_sym
      else
        resources
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 5 rubygems

Version Path
responders-2.4.1 lib/responders/collection_responder.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/responders-2.4.0/lib/responders/collection_responder.rb
responders-2.4.0 lib/responders/collection_responder.rb
responders-2.3.0 lib/responders/collection_responder.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/responders-2.2.0/lib/responders/collection_responder.rb
responders-2.2.0 lib/responders/collection_responder.rb
responders-2.1.2 lib/responders/collection_responder.rb
responders-2.1.1 lib/responders/collection_responder.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/responders-2.1.0/lib/responders/collection_responder.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/responders-2.1.0/lib/responders/collection_responder.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/responders-2.1.0/lib/responders/collection_responder.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/responders-2.1.0/lib/responders/collection_responder.rb
responders-2.1.0 lib/responders/collection_responder.rb
responders-1.1.2 lib/responders/collection_responder.rb
responders-2.0.2 lib/responders/collection_responder.rb
responders-2.0.1 lib/responders/collection_responder.rb
responders-1.1.1 lib/responders/collection_responder.rb
responders-2.0.0 lib/responders/collection_responder.rb
responders-1.1.0 lib/responders/collection_responder.rb
responders-1.0.0 lib/responders/collection_responder.rb