diff --git a/Gemfile b/Gemfile index 5813c25d..4a1edc69 100644 --- a/Gemfile +++ b/Gemfile @@ -20,8 +20,7 @@ gem 'inherited_resources', '~> 1.1.2' gem 'rmagick', '2.12.2' gem 'locomotive_carrierwave', '0.5.0.1.beta3', :require => 'carrierwave' -# gem 'custom_fields', '1.0.0.beta.7' -gem 'custom_fields', '1.0.0.beta.7', :path => '../gems/custom_fields' +gem 'custom_fields', '1.0.0.beta.8' gem 'fog', '0.3.7' gem 'mimetype-fu' gem 'actionmailer-with-request' diff --git a/Gemfile.lock b/Gemfile.lock index 05ba83d7..3dcd91e1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,14 +11,6 @@ GIT xpath (0.1.2) nokogiri (~> 1.4) -PATH - remote: ../gems/custom_fields - specs: - custom_fields (1.0.0.beta.7) - activesupport (>= 3.0.4) - locomotive_carrierwave - mongoid (~> 2.0.0.rc.7) - GEM remote: http://rubygems.org/ specs: @@ -85,6 +77,10 @@ GEM cucumber-rails (0.3.2) cucumber (>= 0.8.0) culerity (0.2.15) + custom_fields (1.0.0.beta.8) + activesupport (>= 3.0.4) + locomotive_carrierwave + mongoid (~> 2.0.0.rc.7) daemons (1.1.0) database_cleaner (0.6.6) delayed_job (2.1.4) @@ -265,7 +261,7 @@ DEPENDENCIES capybara cucumber (= 0.8.5) cucumber-rails - custom_fields (= 1.0.0.beta.7)! + custom_fields (= 1.0.0.beta.8) database_cleaner delayed_job (= 2.1.4) delayed_job_mongoid (= 1.0.2) diff --git a/app/helpers/admin/content_types_helper.rb b/app/helpers/admin/content_types_helper.rb index d62ba726..aa6cd289 100644 --- a/app/helpers/admin/content_types_helper.rb +++ b/app/helpers/admin/content_types_helper.rb @@ -7,23 +7,20 @@ module Admin::ContentTypesHelper @content_types = current_site.content_types.ordered. limit(:contents => Locomotive.config.lastest_items_nb). - only(:name, :slug, :highlighted_field_name, :updated_at).to_a - # only(:name, :slug, :highlighted_field_name, :content_custom_fields_updated_at).to_a + only(:name, :slug, :highlighted_field_name, :content_custom_fields_version).to_a if @content_type && @content_type.persisted? && @content_types.index(@content_type) >= MAX_DISPLAYED_CONTENTS @content_types.delete(@content_type) @content_types.insert(0, @content_type) end - # # be sure, we've got the custom klass up-to-date, otherwise it will fail miserably - # @content_types.each do |content_type| - # # puts "content_type custom_fields !!! ? #{content_type.name} / #{content_type.content_klass.try(:built_at).inspect} / #{content_type.content_custom_fields_updated_at.try(:utc)}" - # if content_type.content_klass_out_of_date? - # puts "RELOADED #{content_type.name}" - # content_type.reload - # content_type.invalidate_content_klass - # end - # end + # be sure, we've got the custom klass up-to-date, otherwise it will fail miserably + @content_types.each do |content_type| + if content_type.content_klass_out_of_date? + content_type.reload + content_type.invalidate_content_klass + end + end @content_types end diff --git a/lib/locomotive/custom_fields.rb b/lib/locomotive/custom_fields.rb index f30e8413..2283f3c8 100644 --- a/lib/locomotive/custom_fields.rb +++ b/lib/locomotive/custom_fields.rb @@ -14,62 +14,7 @@ module CustomFields end end - - module Category # TODO: patch to apply in the next CustomFields version - - module InstanceMethods - - def category_to_hash - { 'category_items' => self.category_items.collect(&:to_hash) } - end - - end - - class Item - - def to_hash(more = {}) - self.fields.keys.inject({}) do |memo, meth| - memo[meth] = self.send(meth.to_sym); memo - end.merge({ - 'id' => self._id, - 'new_record' => self.new_record?, - 'errors' => self.errors - }).merge(more) - end - - def to_json - self.to_hash.to_json - end - - end - end end - - class Field # TODO: patch to apply in the next CustomFields version - - after_save :invalidate_klass - - def to_hash_with_types(more = {}) - to_hash_without_types(more).tap do |hash| - self.class.field_types.keys.each do |type| - if self.respond_to?(:"#{type}_to_hash") - hash.merge!(self.send(:"#{type}_to_hash")) - end - end - end - end - - alias_method_chain :to_hash, :types - - protected - - def invalidate_klass - target_name = self.association_name.to_s.gsub('_custom_fields', '') - self._parent.send(:"invalidate_#{target_name}_klass") - end - - end - end