def to_html
      if get? && resource.is_a?(ActiveRecord::Relation)
        items = process_search resource
        items, paginator = paginate items

        controller.instance_variable_set("@#{controller.controller_name}", items)
        controller.instance_variable_set("@paginator", paginator)
        if request.xhr?
          render controller.params[:action], layout: false
        end

      elsif resource.is_a?(ActiveRecord::Base) && (post? || put?) && resource.valid?
        message = if post?
                    'helpers.messages.create.success'
                  else #put?
                    'helpers.messages.update.success'
                  end
        controller.flash[:success] = I18n.t(message, :model => resource.class.model_name.human)
        redirect_to :action => :show, :id => resource.id

      else
        if delete?
          controller.flash[:success] = I18n.t("helpers.messages.destroy.success", :model => resource.class.model_name.human)
          redirect_to :action => :index
        else
          super
        end
      end
    end
def to_html
      if get? && resource.is_a?(ActiveRecord::Relation)
        items = process_search resource
        items, paginator = paginate items

        controller.instance_variable_set("@#{controller.controller_name}", items)
        controller.instance_variable_set("@paginator", paginator)
        if request.xhr?
          render controller.params[:action], layout: false
        end

      elsif resource.is_a?(ActiveRecord::Base) && (post? || put?) && resource.valid?
        message = if post?
                    'helpers.messages.create.success'
                  else #put?
                    'helpers.messages.update.success'
                  end
        controller.flash[:success] = I18n.t(message, :model => resource.class.model_name.human)
        redirect_to :action => :show, :id => resource.id

      else
        if delete?
          controller.flash[:success] = I18n.t("helpers.messages.destroy.success", :model => resource.class.model_name.human)
          redirect_to :action => :index
        else
          super
        end
      end
    end
=============================================================================
 Responds to HTML format

 It sets flash messages, handles search, sets pagination (@paginator)