Sha256: b68d00f077581d9f37beacab9026ec4b858ecf9b19817eb826ede02802c81f95
Contents?: true
Size: 1.26 KB
Versions: 12
Compression:
Stored size: 1.26 KB
Contents
class Admix::RestController < Admix::AdmixController inherit_resources before_filter -> { if defined?(parent_type) breadcrumbs.add t("#{parent_type.to_s.gsub('_', '').pluralize}.#{parent_type.to_s.gsub('_', '').pluralize}") , polymorphic_path([:admix, parent_class]) breadcrumbs.add "#{parent.name}" , parent_url end } before_filter -> { breadcrumbs.add t("#{collection_name}.#{collection_name}"), collection_url, :i18n => false } before_filter -> { breadcrumbs.add "#{crumb_field}" , resource_url, :i18n => false } , except: [:index, :new, :create ] before_filter -> { breadcrumbs.add t("admix.crud.new.title"), :i18n => false } , only: [:new ] before_filter -> { @crumb_field = crumb_field } , only: [:edit ] protected def crumb_field field_name = if resource.respond_to?(:name) :name elsif resource.respond_to?(:title) :title elsif resource.respond_to?(:email) :email else raise "Implement crumb_field method in #{self}" end resource[field_name] end def load_grid @grid = initialize_grid(resource_class) end def collection_name @collection_name = resource_class.to_s.underscore.pluralize.gsub("::", "_") end def resource_name resource_class.to_s.downcase end end
Version data entries
12 entries across 12 versions & 2 rubygems