Permalink
Browse files

Allow the latest scope to accept how many news items you want to load…

… using an optional argument defaulting to 10.

Credit due to Amanda (http://github.com/awagener) for coming up with the approach used here.
  • Loading branch information...
1 parent 077dfe9 commit e955cf9701658895fa21074f55524e3486ea4d82 @parndt parndt committed Jul 12, 2010
Showing with 5 additions and 5 deletions.
  1. +1 −1 app/models/news_item.rb
  2. +1 −1 lib/news.rb
  3. +1 −1 readme.md
  4. +2 −2 refinerycms-news.gemspec
View
@@ -11,7 +11,7 @@ class NewsItem < ActiveRecord::Base
# If you're using a named scope that includes a changing variable you need to wrap it in a lambda
# This avoids the query being cached thus becoming unaffected by changes (i.e. Time.now is constant)
- named_scope :latest, lambda { { :conditions => ["publish_date < ?", Time.now], :limit => 10 } }
+ named_scope :latest, lambda { |*limit| { :conditions => ["publish_date < ?", Time.now], :limit => (limit.first || 10) } }
named_scope :published, lambda { { :conditions => ["publish_date < ?", Time.now] } }
def not_published? # has the published date not yet arrived?
View
@@ -2,7 +2,7 @@ module Refinery
module News
class << self
def version
- %q{0.9.8}
+ %q{0.9.8.1}
end
end
end
View
@@ -23,7 +23,7 @@ To install the news engine, you can either include the gem or install as a plugi
Include the latest [gem](http://rubygems.org/gems/refinerycms-news) into your Refinery CMS application's Gemfile:
- gem "refinerycms-news", '~> 0.9.8', :require => "news"
+ gem "refinerycms-news", '~> 0.9.8.1', :require => "news"
Then type the following at command line inside your Refinery CMS application's root directory:
View
@@ -1,8 +1,8 @@
Gem::Specification.new do |s|
s.name = %q{refinerycms-news}
- s.version = %q{0.9.8}
+ s.version = %q{0.9.8.1}
s.description = %q{A really straightforward open source Ruby on Rails news engine designed for integration with RefineryCMS.}
- s.date = %q{2010-07-12}
+ s.date = %q{2010-07-13}
s.summary = %q{Ruby on Rails news engine for RefineryCMS.}
s.email = %q{info@refinerycms.com}
s.homepage = %q{http://refinerycms.com}

0 comments on commit e955cf9

Please sign in to comment.