# Combining acts\_as\_taggable, will\_paginate and scope\_out

**URL:** <https://www.ruby-forum.com/t/combining-acts-as-taggable-will-paginate-and-scope-out/166510>\
**Category:** Rails\
**Created:** [April 26, 2009, 4:53pm UTC](https://www.ruby-forum.com/t/combining-acts-as-taggable-will-paginate-and-scope-out/166510 "2009-04-26T16:53:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Commander\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a8b319/32.png) [@Commander\_J](https://www.ruby-forum.com/u/Commander_J)\
**Post date:** [April 26, 2009, 4:53pm UTC](https://www.ruby-forum.com/t/combining-acts-as-taggable-will-paginate-and-scope-out/166510/1 "2009-04-26T16:53:53Z")

</div>

I want to display published posts that are tagged using will\_paginate.  
Options include:

1. Add :conditions =\> { :published =\> true } to the find options. Does  
not  
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 }

Controller:

def tagged\_with  
@tag = params[:id]

```
# Thanks go out to http://blog.wolfman.com/posts/33
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 = Comment.new( :Post => @Post)

```

end

But this yields the error:

test\_show\_nonpublished\_posts(FrontendControllerTest):  
ActiveRecord::RecordNotFound: Couldn’t find Post without an ID  
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active\_record/base.rb:1572:in  
`find_from_ids' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:616:in`find’  
(eval):2:in `find_published' (eval):4:in`with\_published’  
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active\_record/base.rb:2148:in  
`with_scope' (eval):3:in`with\_published’  
(eval):2:in `find\_published’

Any ideas why?

---

<div class="post-metadata">

**Author:** ![Commander\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a8b319/32.png) [@Commander\_J](https://www.ruby-forum.com/u/Commander_J)\
**Post date:** [April 26, 2009, 5:04pm UTC](https://www.ruby-forum.com/t/combining-acts-as-taggable-will-paginate-and-scope-out/166510/2 "2009-04-26T17:04:26Z")

</div>

Found! 😃

Model:

# 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)  
end  
end

Controller:

@posts = Post.paginate\_all\_published\_posts(options)

On Sun, Apr 26, 2009 at 4:52 PM, Commander J. \<
