Hi there, I''ve been trying to paginate over a list of members that all share a tag in common using the acts_as_taggable plugin. The regular way of paginating over a collection doesn''t seem to work with acts_as_taggable. Here''s what my method looks like that takes in a tag name, finds all the members that share the tag and then displays all the members. Nothing too fancy at the moment... def show_all_tags tag_name = params[:id] @tagged_members = Tag.find_by_name(tag_name).tagged end Doing the standard: @tagged_member_pages, @tagged_members = paginate :member, :per_page => 12 displays ALL the members in the DB. Has anyone conquered such an issue like this? Thank you, Dave Hoefler -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060621/82e387ad/attachment.html
On Tuesday, June 20, 2006, at 9:55 PM, Dave Hoefler wrote:>Hi there, > >I''ve been trying to paginate over a list of members that all share a tag in >common using the acts_as_taggable plugin. The regular way of >paginating over >a collection doesn''t seem to work with acts_as_taggable. Here''s what my >method looks like that takes in a tag name, finds all the members >that share >the tag and then displays all the members. Nothing too fancy at the >moment... > >def show_all_tags > tag_name = params[:id] > @tagged_members = Tag.find_by_name(tag_name).tagged >end > >Doing the standard: @tagged_member_pages, @tagged_members = paginate >:member, :per_page => 12 displays ALL the members in the DB. > >Has anyone conquered such an issue like this? > >Thank you, >Dave Hoefler > > >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/rails >You want to do something like this.. def list if params[:tag] then @tags = params[:tag].split.map {|o| CGI::unescape(o)} @items = Item.find_tagged_with(@tags) @item_pages = Paginator.new(ItemController, @items.size, 10) else @item_pages, @items = paginate(:item, :order=>:name) end end just make sure your routes are set up for the :tag option... map.connect '':controller/:action/:tag'', :action => ''index'',:tag=>nil, _Kevin -- Posted with http://DevLists.com. Sign up and save your mailbox.
Hi Kevin, Thank you for the tips. I tried out what you suggested and it works as expected, accpet for one glitch in it. Here''s what my code looks like now: def show_all_tags if params[:id] then @tags = params[:id].split.map {|o| CGI::unescape(o)} @members = Member.find_tagged_with(@tags) @member_pages = Paginator.new(Member, @members.size, 2) else @member_pages, @members = paginate(:member) end end ...and in the view: <div id="menu_links"> <%= pagination_links(@member_pages) %> </div> <div class="members_with_tags"> <% for member in @members %> ....do stuff.... <% end %> I''m still getting all the members showing up, even if I limit the view to 2 members per page. The paginate links show up correctly depending on how many members I designate to show, but the collection of members doesn''t obey the pagination. I have implemented pagination to work correctly in other areas of my app, but using the acts_as_taggable plugin (and methods) may very well be the culprit here. I really have no idea! Any other suggestions? Thanks! -Dave On 21 Jun 2006 03:17:27 -0000, Kevin Olbrich < devlists-rubyonrails@devlists.com> wrote:> > > On Tuesday, June 20, 2006, at 9:55 PM, Dave Hoefler wrote: > >Hi there, > > > >I''ve been trying to paginate over a list of members that all share a tag > in > >common using the acts_as_taggable plugin. The regular way of > >paginating over > >a collection doesn''t seem to work with acts_as_taggable. Here''s what my > >method looks like that takes in a tag name, finds all the members > >that share > >the tag and then displays all the members. Nothing too fancy at the > >moment... > > > >def show_all_tags > > tag_name = params[:id] > > @tagged_members = Tag.find_by_name(tag_name).tagged > >end > > > >Doing the standard: @tagged_member_pages, @tagged_members = paginate > >:member, :per_page => 12 displays ALL the members in the DB. > > > >Has anyone conquered such an issue like this? > > > >Thank you, > >Dave Hoefler > > > > > >_______________________________________________ > >Rails mailing list > >Rails@lists.rubyonrails.org > >http://lists.rubyonrails.org/mailman/listinfo/rails > > > You want to do something like this.. > > def list > if params[:tag] then > @tags = params[:tag].split.map {|o| CGI::unescape(o)} > @items = Item.find_tagged_with(@tags) > @item_pages = Paginator.new(ItemController, @items.size, 10) > else > @item_pages, @items = paginate(:item, :order=>:name) > end > end > > just make sure your routes are set up for the :tag option... > > map.connect '':controller/:action/:tag'', :action => ''index'',:tag=>nil, > > _Kevin > > -- > Posted with http://DevLists.com. Sign up and save your mailbox. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060621/ddf1dff4/attachment.html
On Wednesday, June 21, 2006, at 10:28 AM, Dave Hoefler wrote:>Hi Kevin, > >Thank you for the tips. I tried out what you suggested and it works as >expected, accpet for one glitch in it. Here''s what my code looks like now: > > def show_all_tags > if params[:id] then > @tags = params[:id].split.map {|o| CGI::unescape(o)} > @members = Member.find_tagged_with(@tags) > @member_pages = Paginator.new(Member, @members.size, 2) > else > @member_pages, @members = paginate(:member) > end > end > >...and in the view: > ><div id="menu_links"> > <%= pagination_links(@member_pages) %> ></div> ><div class="members_with_tags"> ><% for member in @members %> > ....do stuff.... ><% end %> > >I''m still getting all the members showing up, even if I limit the view to 2 >members per page. The paginate links show up correctly depending on >how many >members I designate to show, but the collection of members doesn''t obey the >pagination. I have implemented pagination to work correctly in other areas >of my app, but using the acts_as_taggable plugin (and methods) may >very well >be the culprit here. I really have no idea! > >Any other suggestions? > >Thanks! >-Dave > > > >On 21 Jun 2006 03:17:27 -0000, Kevin Olbrich < >devlists-rubyonrails@devlists.com> wrote: >> >> >> On Tuesday, June 20, 2006, at 9:55 PM, Dave Hoefler wrote: >> >Hi there, >> > >> >I''ve been trying to paginate over a list of members that all share a tag >> in >> >common using the acts_as_taggable plugin. The regular way of >> >paginating over >> >a collection doesn''t seem to work with acts_as_taggable. Here''s what my >> >method looks like that takes in a tag name, finds all the members >> >that share >> >the tag and then displays all the members. Nothing too fancy at the >> >moment... >> > >> >def show_all_tags >> > tag_name = params[:id] >> > @tagged_members = Tag.find_by_name(tag_name).tagged >> >end >> > >> >Doing the standard: @tagged_member_pages, @tagged_members = paginate >> >:member, :per_page => 12 displays ALL the members in the DB. >> > >> >Has anyone conquered such an issue like this? >> > >> >Thank you, >> >Dave Hoefler >> > >> > >> >_______________________________________________ >> >Rails mailing list >> >Rails@lists.rubyonrails.org >> >http://lists.rubyonrails.org/mailman/listinfo/rails >> > >> You want to do something like this.. >> >> def list >> if params[:tag] then >> @tags = params[:tag].split.map {|o| CGI::unescape(o)} >> @items = Item.find_tagged_with(@tags) >> @item_pages = Paginator.new(ItemController, @items.size, 10) >> else >> @item_pages, @items = paginate(:item, :order=>:name) >> end >> end >> >> just make sure your routes are set up for the :tag option... >> >> map.connect '':controller/:action/:tag'', :action => ''index'',:tag=>nil, >> >> _Kevin >> >> -- >> Posted with http://DevLists.com. Sign up and save your mailbox. >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > > >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/rails >It looks like your action is falling through to the else clause. throw line like this in these before the paginate function raise ''test'' If it generates an error when you hit the action, then it''s not pulling the id out properly. What does the url you are accessing the action with look like? What do your routes look like? _Kevin -- Posted with http://DevLists.com. Sign up and save your mailbox.
Hi Kevin, I put the raise ''test'' in before the paginate function, and when I run it I do see "test" in my browser. I also put a redirect to a general list action if no params come through. The "else" part of the block does work correctly. def show_all_tags if params[:id] then @tag_title = params[:id] @tags = params[:id].split.map {|o| CGI::unescape(o)} @members = Member.find_tagged_with(@tags) raise ''test'' @members_pages = Paginator.new(Member, @members.size, 2) else redirect_to :action => ''list'' end end My route for this action looks like this: map.connect ''tags/:id'', :controller => ''member'', :action => ''show_all_tags'' This URL does display members with a common tag: http://localhost:3000/tags/photographer This URL does redirect back to a "list" action if no tag is present http://localhost:3000/tags/ -Dave On 21 Jun 2006 17:24:07 -0000, Kevin Olbrich < devlists-rubyonrails@devlists.com> wrote:> > > On Wednesday, June 21, 2006, at 10:28 AM, Dave Hoefler wrote: > >Hi Kevin, > > > >Thank you for the tips. I tried out what you suggested and it works as > >expected, accpet for one glitch in it. Here''s what my code looks like > now: > > > > def show_all_tags > > if params[:id] then > > @tags = params[:id].split.map {|o| CGI::unescape(o)} > > @members = Member.find_tagged_with(@tags) > > @member_pages = Paginator.new(Member, @members.size, 2) > > else > > @member_pages, @members = paginate(:member) > > end > > end > > > >...and in the view: > > > ><div id="menu_links"> > > <%= pagination_links(@member_pages) %> > ></div> > ><div class="members_with_tags"> > ><% for member in @members %> > > ....do stuff.... > ><% end %> > > > >I''m still getting all the members showing up, even if I limit the view to > 2 > >members per page. The paginate links show up correctly depending on > >how many > >members I designate to show, but the collection of members doesn''t obey > the > >pagination. I have implemented pagination to work correctly in other > areas > >of my app, but using the acts_as_taggable plugin (and methods) may > >very well > >be the culprit here. I really have no idea! > > > >Any other suggestions? > > > >Thanks! > >-Dave > > > > > > > >On 21 Jun 2006 03:17:27 -0000, Kevin Olbrich < > >devlists-rubyonrails@devlists.com> wrote: > >> > >> > >> On Tuesday, June 20, 2006, at 9:55 PM, Dave Hoefler wrote: > >> >Hi there, > >> > > >> >I''ve been trying to paginate over a list of members that all share a > tag > >> in > >> >common using the acts_as_taggable plugin. The regular way of > >> >paginating over > >> >a collection doesn''t seem to work with acts_as_taggable. Here''s what > my > >> >method looks like that takes in a tag name, finds all the members > >> >that share > >> >the tag and then displays all the members. Nothing too fancy at the > >> >moment... > >> > > >> >def show_all_tags > >> > tag_name = params[:id] > >> > @tagged_members = Tag.find_by_name(tag_name).tagged > >> >end > >> > > >> >Doing the standard: @tagged_member_pages, @tagged_members = paginate > >> >:member, :per_page => 12 displays ALL the members in the DB. > >> > > >> >Has anyone conquered such an issue like this? > >> > > >> >Thank you, > >> >Dave Hoefler > >> > > >> > > >> >_______________________________________________ > >> >Rails mailing list > >> >Rails@lists.rubyonrails.org > >> >http://lists.rubyonrails.org/mailman/listinfo/rails > >> > > >> You want to do something like this.. > >> > >> def list > >> if params[:tag] then > >> @tags = params[:tag].split.map {|o| CGI::unescape(o)} > >> @items = Item.find_tagged_with(@tags) > >> @item_pages = Paginator.new(ItemController, @items.size, 10) > >> else > >> @item_pages, @items = paginate(:item, :order=>:name) > >> end > >> end > >> > >> just make sure your routes are set up for the :tag option... > >> > >> map.connect '':controller/:action/:tag'', :action => ''index'',:tag=>nil, > >> > >> _Kevin > >> > >> -- > >> Posted with http://DevLists.com. Sign up and save your mailbox. > >> _______________________________________________ > >> Rails mailing list > >> Rails@lists.rubyonrails.org > >> http://lists.rubyonrails.org/mailman/listinfo/rails > >> > > > > > >_______________________________________________ > >Rails mailing list > >Rails@lists.rubyonrails.org > >http://lists.rubyonrails.org/mailman/listinfo/rails > > > > It looks like your action is falling through to the else clause. > throw line like this in these before the paginate function > > raise ''test'' > > If it generates an error when you hit the action, then it''s not pulling > the id out properly. > > What does the url you are accessing the action with look like? > What do your routes look like? > > _Kevin > > -- > Posted with http://DevLists.com. Sign up and save your mailbox. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060621/39b7c1f8/attachment.html
I found the following bit of code here (on the bottom of the page): http://wiki.rubyonrails.org/rails/pages/ActsAsTaggablePluginHowto/versions/59 module ActionController module Pagination MY_OPTIONS = {:tag => ''All''} DEFAULT_OPTIONS.merge!(MY_OPTIONS) {|key, old, new| old} alias old_find_collection_for_pagination find_collection_for_pagination def find_collection_for_pagination(model, options, paginator) models = old_find_collection_for_pagination(model, options, paginator) if options[:tag]=="All" models else models.delete_if {|m| !m.is_tagged_with?(options[:tag])} end end end end ...but really have no idea WHERE to put it in the acts_as_taggable.rb file. How would you actually use something like this? Do you think this is a viable option? Here''s the description of it: *Note* *Acts_as_taggeble with pagination* The following opens the pagination class back up adds the abilty to filter based on a single tag. Pass a :tag => "tag" and the pagination with be base on though s items that are tagged with it. Belongs in acts_as_taggable.rb. EO -Dave On 6/21/06, Dave Hoefler <dhoefler@gmail.com> wrote:> > Hi Kevin, > > I put the raise ''test'' in before the paginate function, and when I run it > I do see "test" in my browser. I also put a redirect to a general list > action if no params come through. The "else" part of the block does work > correctly. > > > > def show_all_tags > if params[:id] then > @tag_title = params[:id] > > @tags = params[:id].split.map {|o| CGI::unescape(o)} > @members = Member.find_tagged_with(@tags) > raise ''test'' > @members_pages = Paginator.new(Member, @members.size, 2) > else > redirect_to :action => ''list'' > end > end > > > My route for this action looks like this: > > map.connect ''tags/:id'', :controller => ''member'', :action => > ''show_all_tags'' > > This URL does display members with a common tag: > http://localhost:3000/tags/photographer > > This URL does redirect back to a "list" action if no tag is present > http://localhost:3000/tags/ > > -Dave > > > > On 21 Jun 2006 17:24:07 -0000, Kevin Olbrich < > devlists-rubyonrails@devlists.com> wrote: > > > > > > On Wednesday, June 21, 2006, at 10:28 AM, Dave Hoefler wrote: > > >Hi Kevin, > > > > > >Thank you for the tips. I tried out what you suggested and it works as > > >expected, accpet for one glitch in it. Here''s what my code looks like > > now: > > > > > > def show_all_tags > > > if params[:id] then > > > @tags = params[:id].split.map {|o| CGI::unescape(o)} > > > @members = Member.find_tagged_with(@tags) > > > @member_pages = Paginator.new(Member, @members.size, 2) > > > else > > > @member_pages, @members = paginate(:member) > > > end > > > end > > > > > >...and in the view: > > > > > ><div id="menu_links"> > > > <%= pagination_links(@member_pages) %> > > ></div> > > ><div class="members_with_tags"> > > ><% for member in @members %> > > > ....do stuff.... > > ><% end %> > > > > > >I''m still getting all the members showing up, even if I limit the view > > to 2 > > >members per page. The paginate links show up correctly depending on > > >how many > > >members I designate to show, but the collection of members doesn''t obey > > the > > >pagination. I have implemented pagination to work correctly in other > > areas > > >of my app, but using the acts_as_taggable plugin (and methods) may > > >very well > > >be the culprit here. I really have no idea! > > > > > >Any other suggestions? > > > > > >Thanks! > > >-Dave > > > > > > > > > > > >On 21 Jun 2006 03:17:27 -0000, Kevin Olbrich < > > >devlists-rubyonrails@devlists.com> wrote: > > >> > > >> > > >> On Tuesday, June 20, 2006, at 9:55 PM, Dave Hoefler wrote: > > >> >Hi there, > > >> > > > >> >I''ve been trying to paginate over a list of members that all share a > > tag > > >> in > > >> >common using the acts_as_taggable plugin. The regular way of > > >> >paginating over > > >> >a collection doesn''t seem to work with acts_as_taggable. Here''s what > > my > > >> >method looks like that takes in a tag name, finds all the members > > >> >that share > > >> >the tag and then displays all the members. Nothing too fancy at the > > >> >moment... > > >> > > > >> >def show_all_tags > > >> > tag_name = params[:id] > > >> > @tagged_members = Tag.find_by_name(tag_name).tagged > > >> >end > > >> > > > >> >Doing the standard: @tagged_member_pages, @tagged_members > > paginate > > >> >:member, :per_page => 12 displays ALL the members in the DB. > > >> > > > >> >Has anyone conquered such an issue like this? > > >> > > > >> >Thank you, > > >> >Dave Hoefler > > >> > > > >> > > > >> >_______________________________________________ > > >> >Rails mailing list > > >> > Rails@lists.rubyonrails.org > > >> >http://lists.rubyonrails.org/mailman/listinfo/rails > > >> > > > >> You want to do something like this.. > > >> > > >> def list > > >> if params[:tag] then > > >> @tags = params[:tag].split.map {|o| CGI::unescape(o)} > > >> @items = Item.find_tagged_with (@tags) > > >> @item_pages = Paginator.new(ItemController, @items.size, 10) > > >> else > > >> @item_pages, @items = paginate(:item, :order=>:name) > > >> end > > >> end > > >> > > >> just make sure your routes are set up for the :tag option... > > >> > > >> map.connect '':controller/:action/:tag'', :action => ''index'',:tag=>nil, > > >> > > >> _Kevin > > >> > > >> -- > > >> Posted with http://DevLists.com. Sign up and save your mailbox. > > >> _______________________________________________ > > >> Rails mailing list > > >> Rails@lists.rubyonrails.org > > >> http://lists.rubyonrails.org/mailman/listinfo/rails > > >> > > > > > > > > >_______________________________________________ > > >Rails mailing list > > >Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > It looks like your action is falling through to the else clause. > > throw line like this in these before the paginate function > > > > raise ''test'' > > > > If it generates an error when you hit the action, then it''s not pulling > > the id out properly. > > > > What does the url you are accessing the action with look like? > > What do your routes look like? > > > > _Kevin > > > > -- > > Posted with http://DevLists.com. Sign up and save your mailbox. > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060621/24ac0f14/attachment-0001.html
On Wednesday, June 21, 2006, at 1:38 PM, Dave Hoefler wrote:>Hi Kevin, > >I put the raise ''test'' in before the paginate function, and when I run it I >do see "test" in my browser. I also put a redirect to a general list action >if no params come through. The "else" part of the block does work >correctly. > > > def show_all_tags > if params[:id] then > @tag_title = params[:id] > @tags = params[:id].split.map {|o| CGI::unescape(o)} > @members = Member.find_tagged_with(@tags) > raise ''test'' > @members_pages = Paginator.new(Member, @members.size, 2) > else > redirect_to :action => ''list'' > end > end > > >My route for this action looks like this: > >map.connect ''tags/:id'', :controller => ''member'', :action => ''show_all_tags'' > >This URL does display members with a common tag: >http://localhost:3000/tags/photographer > >This URL does redirect back to a "list" action if no tag is present >http://localhost:3000/tags/ > >-Dave > > >On 21 Jun 2006 17:24:07 -0000, Kevin Olbrich < >devlists-rubyonrails@devlists.com> wrote: >> >> >> On Wednesday, June 21, 2006, at 10:28 AM, Dave Hoefler wrote: >> >Hi Kevin, >> > >> >Thank you for the tips. I tried out what you suggested and it works as >> >expected, accpet for one glitch in it. Here''s what my code looks like >> now: >> > >> > def show_all_tags >> > if params[:id] then >> > @tags = params[:id].split.map {|o| CGI::unescape(o)} >> > @members = Member.find_tagged_with(@tags) >> > @member_pages = Paginator.new(Member, @members.size, 2) >> > else >> > @member_pages, @members = paginate(:member) >> > end >> > end >> > >> >...and in the view: >> > >> ><div id="menu_links"> >> > <%= pagination_links(@member_pages) %> >> ></div> >> ><div class="members_with_tags"> >> ><% for member in @members %> >> > ....do stuff.... >> ><% end %> >> > >> >I''m still getting all the members showing up, even if I limit the >>view to >> 2 >> >members per page. The paginate links show up correctly depending on >> >how many >> >members I designate to show, but the collection of members doesn''t obey >> the >> >pagination. I have implemented pagination to work correctly in other >> areas >> >of my app, but using the acts_as_taggable plugin (and methods) may >> >very well >> >be the culprit here. I really have no idea! >> > >> >Any other suggestions? >> > >> >Thanks! >> >-Dave >> > >> > >> > >> >On 21 Jun 2006 03:17:27 -0000, Kevin Olbrich < >> >devlists-rubyonrails@devlists.com> wrote: >> >> >> >> >> >> On Tuesday, June 20, 2006, at 9:55 PM, Dave Hoefler wrote: >> >> >Hi there, >> >> > >> >> >I''ve been trying to paginate over a list of members that all share a >> tag >> >> in >> >> >common using the acts_as_taggable plugin. The regular way of >> >> >paginating over >> >> >a collection doesn''t seem to work with acts_as_taggable. Here''s what >> my >> >> >method looks like that takes in a tag name, finds all the members >> >> >that share >> >> >the tag and then displays all the members. Nothing too fancy at the >> >> >moment... >> >> > >> >> >def show_all_tags >> >> > tag_name = params[:id] >> >> > @tagged_members = Tag.find_by_name(tag_name).tagged >> >> >end >> >> > >> >> >Doing the standard: @tagged_member_pages, @tagged_members >>paginate >> >> >:member, :per_page => 12 displays ALL the members in the DB. >> >> > >> >> >Has anyone conquered such an issue like this? >> >> > >> >> >Thank you, >> >> >Dave Hoefler >> >> > >> >> > >> >> >_______________________________________________ >> >> >Rails mailing list >> >> >Rails@lists.rubyonrails.org >> >> >http://lists.rubyonrails.org/mailman/listinfo/rails >> >> > >> >> You want to do something like this.. >> >> >> >> def list >> >> if params[:tag] then >> >> @tags = params[:tag].split.map {|o| CGI::unescape(o)} >> >> @items = Item.find_tagged_with(@tags) >> >> @item_pages = Paginator.new(ItemController, @items.size, 10) >> >> else >> >> @item_pages, @items = paginate(:item, :order=>:name) >> >> end >> >> end >> >> >> >> just make sure your routes are set up for the :tag option... >> >> >> >> map.connect '':controller/:action/:tag'', :action => ''index'',:tag=>nil, >> >> >> >> _Kevin >> >> >> >> -- >> >> Posted with http://DevLists.com. Sign up and save your mailbox. >> >> _______________________________________________ >> >> Rails mailing list >> >> Rails@lists.rubyonrails.org >> >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> >> > >> > >> >_______________________________________________ >> >Rails mailing list >> >Rails@lists.rubyonrails.org >> >http://lists.rubyonrails.org/mailman/listinfo/rails >> > >> >> It looks like your action is falling through to the else clause. >> throw line like this in these before the paginate function >> >> raise ''test'' >> >> If it generates an error when you hit the action, then it''s not pulling >> the id out properly. >> >> What does the url you are accessing the action with look like? >> What do your routes look like? >> >> _Kevin >> >> -- >> Posted with http://DevLists.com. Sign up and save your mailbox. >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > > >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/rails >I think your line like this... @member_pages = Paginator.new(Member, @members.size, 2) should actually be @member_pages = Paginator.new(MemberController, @members.size, 2) _Kevin -- Posted with http://DevLists.com. Sign up and save your mailbox.
Hi Kevin (again), I tried the MemberController change and that still didn''t work. However... good news... I did solve it with the following code: def show_all_tags per_page = 12 if params[:id] then @tag_title = params[:id] @tags = params[:id].split.map {|o| CGI::unescape(o)} @members = Member.find_tagged_with(@tags) @members_pages, @members = paginate(Member, {:conditions => ['' tags.name = ?'', @tag_title], :include => [:tags], :per_page => per_page}) else redirect_to :action => ''list'' end end Thank you for all your help! -Dave Hoefler On 21 Jun 2006 20:15:10 -0000, Kevin Olbrich < devlists-rubyonrails@devlists.com> wrote:> > > On Wednesday, June 21, 2006, at 1:38 PM, Dave Hoefler wrote: > >Hi Kevin, > > > >I put the raise ''test'' in before the paginate function, and when I run it > I > >do see "test" in my browser. I also put a redirect to a general list > action > >if no params come through. The "else" part of the block does work > >correctly. > > > > > > def show_all_tags > > if params[:id] then > > @tag_title = params[:id] > > @tags = params[:id].split.map {|o| CGI::unescape(o)} > > @members = Member.find_tagged_with(@tags) > > raise ''test'' > > @members_pages = Paginator.new(Member, @members.size, 2) > > else > > redirect_to :action => ''list'' > > end > > end > > > > > >My route for this action looks like this: > > > >map.connect ''tags/:id'', :controller => ''member'', :action => > ''show_all_tags'' > > > >This URL does display members with a common tag: > >http://localhost:3000/tags/photographer > > > >This URL does redirect back to a "list" action if no tag is present > >http://localhost:3000/tags/ > > > >-Dave > > > > > >On 21 Jun 2006 17:24:07 -0000, Kevin Olbrich < > >devlists-rubyonrails@devlists.com> wrote: > >> > >> > >> On Wednesday, June 21, 2006, at 10:28 AM, Dave Hoefler wrote: > >> >Hi Kevin, > >> > > >> >Thank you for the tips. I tried out what you suggested and it works as > >> >expected, accpet for one glitch in it. Here''s what my code looks like > >> now: > >> > > >> > def show_all_tags > >> > if params[:id] then > >> > @tags = params[:id].split.map {|o| CGI::unescape(o)} > >> > @members = Member.find_tagged_with(@tags) > >> > @member_pages = Paginator.new(Member, @members.size, 2) > >> > else > >> > @member_pages, @members = paginate(:member) > >> > end > >> > end > >> > > >> >...and in the view: > >> > > >> ><div id="menu_links"> > >> > <%= pagination_links(@member_pages) %> > >> ></div> > >> ><div class="members_with_tags"> > >> ><% for member in @members %> > >> > ....do stuff.... > >> ><% end %> > >> > > >> >I''m still getting all the members showing up, even if I limit the > >>view to > >> 2 > >> >members per page. The paginate links show up correctly depending on > >> >how many > >> >members I designate to show, but the collection of members doesn''t > obey > >> the > >> >pagination. I have implemented pagination to work correctly in other > >> areas > >> >of my app, but using the acts_as_taggable plugin (and methods) may > >> >very well > >> >be the culprit here. I really have no idea! > >> > > >> >Any other suggestions? > >> > > >> >Thanks! > >> >-Dave > >> > > >> > > >> > > >> >On 21 Jun 2006 03:17:27 -0000, Kevin Olbrich < > >> >devlists-rubyonrails@devlists.com> wrote: > >> >> > >> >> > >> >> On Tuesday, June 20, 2006, at 9:55 PM, Dave Hoefler wrote: > >> >> >Hi there, > >> >> > > >> >> >I''ve been trying to paginate over a list of members that all share > a > >> tag > >> >> in > >> >> >common using the acts_as_taggable plugin. The regular way of > >> >> >paginating over > >> >> >a collection doesn''t seem to work with acts_as_taggable. Here''s > what > >> my > >> >> >method looks like that takes in a tag name, finds all the members > >> >> >that share > >> >> >the tag and then displays all the members. Nothing too fancy at the > >> >> >moment... > >> >> > > >> >> >def show_all_tags > >> >> > tag_name = params[:id] > >> >> > @tagged_members = Tag.find_by_name(tag_name).tagged > >> >> >end > >> >> > > >> >> >Doing the standard: @tagged_member_pages, @tagged_members > >>paginate > >> >> >:member, :per_page => 12 displays ALL the members in the DB. > >> >> > > >> >> >Has anyone conquered such an issue like this? > >> >> > > >> >> >Thank you, > >> >> >Dave Hoefler > >> >> > > >> >> > > >> >> >_______________________________________________ > >> >> >Rails mailing list > >> >> >Rails@lists.rubyonrails.org > >> >> >http://lists.rubyonrails.org/mailman/listinfo/rails > >> >> > > >> >> You want to do something like this.. > >> >> > >> >> def list > >> >> if params[:tag] then > >> >> @tags = params[:tag].split.map {|o| CGI::unescape(o)} > >> >> @items = Item.find_tagged_with(@tags) > >> >> @item_pages = Paginator.new(ItemController, @items.size, 10) > >> >> else > >> >> @item_pages, @items = paginate(:item, :order=>:name) > >> >> end > >> >> end > >> >> > >> >> just make sure your routes are set up for the :tag option... > >> >> > >> >> map.connect '':controller/:action/:tag'', :action => > ''index'',:tag=>nil, > >> >> > >> >> _Kevin > >> >> > >> >> -- > >> >> Posted with http://DevLists.com. Sign up and save your mailbox. > >> >> _______________________________________________ > >> >> Rails mailing list > >> >> Rails@lists.rubyonrails.org > >> >> http://lists.rubyonrails.org/mailman/listinfo/rails > >> >> > >> > > >> > > >> >_______________________________________________ > >> >Rails mailing list > >> >Rails@lists.rubyonrails.org > >> >http://lists.rubyonrails.org/mailman/listinfo/rails > >> > > >> > >> It looks like your action is falling through to the else clause. > >> throw line like this in these before the paginate function > >> > >> raise ''test'' > >> > >> If it generates an error when you hit the action, then it''s not pulling > >> the id out properly. > >> > >> What does the url you are accessing the action with look like? > >> What do your routes look like? > >> > >> _Kevin > >> > >> -- > >> Posted with http://DevLists.com. Sign up and save your mailbox. > >> _______________________________________________ > >> Rails mailing list > >> Rails@lists.rubyonrails.org > >> http://lists.rubyonrails.org/mailman/listinfo/rails > >> > > > > > >_______________________________________________ > >Rails mailing list > >Rails@lists.rubyonrails.org > >http://lists.rubyonrails.org/mailman/listinfo/rails > > > > I think your line like this... > > @member_pages = Paginator.new(Member, @members.size, 2) > > should actually be > > @member_pages = Paginator.new(MemberController, @members.size, 2) > > > > _Kevin > > -- > Posted with http://DevLists.com. Sign up and save your mailbox. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060621/ce31ffd7/attachment.html