lib/active_admin/resource.rb in activeadmin-2.2.0 vs lib/active_admin/resource.rb in activeadmin-2.3.0

- old
+ new

@@ -10,10 +10,11 @@ require 'active_admin/resource/includes' require 'active_admin/resource/scope_to' require 'active_admin/resource/sidebars' require 'active_admin/resource/belongs_to' require 'active_admin/resource/ordering' +require 'active_admin/resource/model' module ActiveAdmin # Resource is the primary data storage for resource configuration in Active Admin # @@ -102,10 +103,14 @@ def decorator_class ActiveSupport::Dependencies.constantize(decorator_class_name) if decorator_class_name end + def resource_name_extension + @resource_name_extension ||= define_resource_name_extension(self) + end + def resource_table_name resource_class.quoted_table_name end def resource_column_names @@ -131,10 +136,11 @@ end def belongs_to(target, options = {}) @belongs_to = Resource::BelongsTo.new(self, target, options) self.menu_item_options = false if @belongs_to.required? + options[:class_name] ||= @belongs_to.resource.resource_class_name if @belongs_to.resource controller.send :belongs_to, target, options.dup end def belongs_to_config @belongs_to @@ -201,7 +207,14 @@ def default_csv_builder @default_csv_builder ||= CSVBuilder.default_for_resource(self) end + def define_resource_name_extension(resource) + Module.new do + define_method :model_name do + resource.resource_name + end + end + end end # class Resource end # module ActiveAdmin