Sha256: 9d2ff65e8f9607a42792ae913327057231851c4539fc03ab1e763c0ecaca952a
Contents?: true
Size: 836 Bytes
Versions: 8
Compression:
Stored size: 836 Bytes
Contents
# frozen_string_literal: true module C module PagesHelper def get_page(model, url=params[:id]) @page = if !url.present? || (url =~ /[^0-9]/) model.get_from_url(url) else # This is accommodating a use-case that *will* result in problems, given enough products model.find_by(id: url) || model.get_from_url(url) end begin @page_info = @page.page_info rescue NoMethodError raise ActiveRecord::RecordNotFound end if @page.respond_to?('layout') && !@page.layout.blank? && @page.layout != 'show' @render = @page.layout else @page end end def force_clean_url(object) redirect_to [:front_end, object] if object.url_alias && params[:id] != object.url_alias end end end
Version data entries
8 entries across 8 versions & 1 rubygems