From 1a6ac2de822e4e263e428aae0f4c10f1155b67c9 Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Thu, 30 Jan 2014 14:05:53 -0300 Subject: [PATCH] rails3: use settings_items for limit on rss_feed --- app/models/rss_feed.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/rss_feed.rb b/app/models/rss_feed.rb index b42ac4d..2de235d 100644 --- a/app/models/rss_feed.rb +++ b/app/models/rss_feed.rb @@ -28,16 +28,16 @@ class RssFeed < Article self.body[:feed_item_description] = feed_item_description end - # The maximum number of articles to be displayed in the RSS feed. Default: 10 - def limit - settings[:limit] || 10 - end - def limit=(value) + settings_items :limit, :type => :integer, :default => 10 + + def limit_with_body_change=(value) #UPGRADE Leandro: I add this line to save the serialize attribute self.body_will_change! - settings[:limit] = value + self.limit_without_body_change= value end + alias_method_chain :limit=, :body_change + # FIXME this should be validates_numericality_of, but Rails 2.0.2 does not # support validates_numericality_of with virtual attributes validates_format_of :limit, :with => /^\d+$/, :if => :limit -- libgit2 0.21.2