Sha256: 8441f6d04e3f5a7258df5882d8945604d4f4233bd3e9a8317086aae83219ec24
Contents?: true
Size: 1.22 KB
Versions: 5
Compression:
Stored size: 1.22 KB
Contents
class Backend::RedirectsController < BackendController include Concerns::PaginationController before_action -> { breadcrumb.add t('b.redirects'), backend_redirects_path } before_action :find_model, only: [:edit, :update, :destroy] def index @search = ::Redirect.ransack params[:q] @redirects = @search.result(distinct: true).order('times_used DESC').page(page_number).per_page(per_page) end def new @redirect = ::Redirect.new(status_code: 301).decorate end def create @redirect = ::Redirect.new(allowed_params).decorate if @redirect.save redirect_to backend_redirects_path, notice: translate_notice(:added, :redirect) else render :new end end def destroy @redirect.destroy redirect_to backend_redirects_path, notice: translate_notice(:deleted, :redirect) end def update if @redirect.update_attributes allowed_params redirect_to backend_redirects_path, notice: translate_notice(:edited, :redirect) else render :edit end end private def allowed_params params.require(:redirect).permit( :source_uri, :destination_uri, :status_code, :disabled ) end def find_model @redirect = ::Redirect.find(params[:id]).decorate end end
Version data entries
5 entries across 5 versions & 1 rubygems