Sha256: 02ba8a41162ee4960c4233a2e52446e8e2de05a1ca85d09759ab987a4ff1c614
Contents?: true
Size: 1.18 KB
Versions: 8
Compression:
Stored size: 1.18 KB
Contents
module Storytime::PostPartialInheritance extend ActiveSupport::Concern module ClassMethods # Tries to render the appropriate partial, respecting inheritance and per-site overrides # Order of preference (lowest is last) looks something like: # storytime/views/site-name/blog_posts/blog_post # storytime/views/blog_posts/blog_post # storytime/views/site-name/posts/post # storytime/views/post/post def _to_partial_path(site) @_to_partial_path ||= begin element = ActiveSupport::Inflector.underscore(ActiveSupport::Inflector.demodulize(self)) collection = ActiveSupport::Inflector.tableize(self.to_s) if site && File.exists?(Rails.root.join('app', 'views', "storytime/#{site.custom_view_path}/#{collection.sub("storytime/", "")}/_#{element}.html.erb")) "storytime/#{site.custom_view_path}/#{collection.sub("storytime/", "")}/#{element}" elsif File.exists?(Rails.root.join('app', 'views', collection, "_#{element}.html.erb")) || self.superclass == ActiveRecord::Base "#{collection}/#{element}" else self.superclass._to_partial_path(site) end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems