Forum: Ruby on Rails Combining acts_as_taggable, will_paginate and scope_out

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Commander J. (Guest)
on 2009-04-26 18:53
(Received via mailing list)
I want to display published posts that are tagged using will_paginate.
Options include:

1. Add :conditions => { :published => true } to the find options. Does
work because will_paginate will then return too many records.
2. Use scope_out in class Post like this:

scope_out :published, :conditions => { :published => true }


  def tagged_with
    @tag = params[:id]

    # Thanks go out to
    options = Post.find_options_for_find_tagged_with(@tag).merge(:page
params[:page], :per_page => property(:items_per_page))
    #@posts = Post.paginate(options)
    @posts = Post.paginate_published(options)

    redirect_to :action => :tag_not_found if @Posts.empty?

    # Create a new comment in memory
    @comment = :Post => @Post)

But this yields the error:

ActiveRecord::RecordNotFound: Couldn't find Post without an ID
(eval):2:in `find_published'
(eval):4:in `with_published'
(eval):3:in `with_published'
(eval):2:in `find_published'

Any ideas why?
Commander J. (Guest)
on 2009-04-26 19:04
(Received via mailing list)
Found! :D


  # XXL name to prevent override meta-methods such as paginate_published
  def self.paginate_all_published_posts(options)
    self.with_published do
      return self.paginate(options)


@posts = Post.paginate_all_published_posts(options)

On Sun, Apr 26, 2009 at 4:52 PM, Commander J. <
This topic is locked and can not be replied to.