app/controllers/admin/cms_controller.rb
def respond_after_action( action, verb )

      # work out where we’re going
      new_url = params.key?( :back_to ) || url_for( action: :index, only_path: true )

      # if there’s an override…
      if @redirects.key?( action ) and !@redirects[action].nil?

        new_url = @redirects[action].respond_to?( :call ) ? @redirects[action].call( @content || @model_class ) : @redirects[action]

      end

      # we now have a URL, so switch on format
      respond_to do |format|

        # HTML gets a flash and a bounce
        format.html do

          flash[:success] = status_t( @content, verb, title: @content.to_s )
          redirect_to( new_url )

        end

        # JSON just gets JSON
        format.json { render action: :show }

      end

    end
# Utility function that bounces the user to a different page after successfully creating/updating/destroying an
# item of content.
#
# === Parameters
#
# [action]  the action that has just happened
# [verb]    the verb to use for localisation
Utility function that bounces the user to a different page after successfully creating/updating/destroying an
item of content.

Parameters

[action]  the action that has just happened
[verb]    the verb to use for localisation
Utility function that bounces the user to a different page after successfully creating / updating / destroying an item of content . Parameters [ action ] the action that has just happened [ verb ] the verb to use for localisation
def respond_after_action( action, verb )
      new_url = params.key?( :back_to ) || url_for( action: :index, only_path: true )
      if @redirects.key?( action ) and !@redirects[action].nil?
        new_url = @redirects[action].respond_to?( :call ) ? @redirects[action].call( @content || @model_class ) : @redirects[action]
      end
      respond_to do |format|
        format.html do
          flash[:success] = status_t( @content, verb, title: @content.to_s )
          redirect_to( new_url )
        end
        format.json { render action: :show }
      end
    end
def respond_after_action ( action , verb ) new_url = params . key? ( :back_to ) || url_for ( action : :index , only_path : true ) if @redirects . key? ( action ) and ! @redirects [ action ] . nil? new_url = @redirects [ action ] . respond_to? ( :call ) ? @redirects [ action ] . call ( @content || @model_class ) : @redirects [ action ] end respond_to do | format | format . html do flash [ :success ] = status_t ( @content , verb , title : @content . to_s ) redirect_to ( new_url ) end format . json { render action : :show } end end
Utility function that bounces the user to a different page after successfully creating/updating/destroying an
item of content.
Utility function that bounces the user to a different page after successfully creating / updating / destroying an item of content .
# work out where we’re going # if there’s an override… # we now have a URL, so switch on format # HTML gets a flash and a bounce # JSON just gets JSON
action
verb