lib/cms/behaviors/connecting.rb in browsercms-3.3.4 vs lib/cms/behaviors/connecting.rb in browsercms-3.4.0.rc1
- old
+ new
@@ -1,8 +1,12 @@
module Cms
module Behaviors
module Connecting
+
+ def self.default_naming_for(klass)
+ klass.name.demodulize.titleize
+ end
def self.included(model_class)
model_class.extend(MacroMethods)
end
module MacroMethods
def connectable?
@@ -15,26 +19,27 @@
attr_accessor :connect_to_page_id
attr_accessor :connect_to_container
attr_accessor :connected_page
- has_many :connectors, :as => :connectable
+ has_many :connectors, :as => :connectable, :class_name => 'Cms::Connector'
attr_accessor :updated_by_page
after_create :connect_to_page
after_save :update_connected_pages, :unless=>:skip_callbacks
end
end
module ClassMethods
+
def content_block_type
- to_s.underscore
+ ActiveModel::Naming.singular(self)
end
def display_name
- to_s.titleize
+ Connecting.default_naming_for(self)
end
def display_name_plural
display_name.pluralize
end
end
@@ -89,10 +94,10 @@
# This is needed in the case of updating page,
# which updates this object, so as not to create a loop
if p != updated_by_page
#This just creates a new version of the page
action = deleted? ? "Deleted" : "Edited"
- p.update_attributes(:version_comment => "#{self.class.name} ##{id} was #{action}")
+ p.update_attributes(:version_comment => "#{self.class.name.demodulize} ##{id} was #{action}")
#The previous step will copy over a connector pointing to the previous version of this connectable
#We need to change that to point at the new version of this connectable
connectors_for_page = p.connectors
# puts "cfp #{connectors_for_page}"