Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6779337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:22:24+00:00 2026-05-26T16:22:24+00:00

I’m currently using the following gems in my application to provide pagination, search, linkable

  • 0

I’m currently using the following gems in my application to provide pagination, search, linkable tags, and a tag cloud.

gem ‘will_paginate’, ‘~> 3.0.2’
gem ‘acts-as-taggable-on’, ‘~>2.1.0’

I have everything implemented so far in Rails 3.1 except the tag links. I have them displayed below every post and in the tag cloud and both link to different views and neither works.

A link in the tag cloud (Test1) links me to: /posts/tag?id=Test1 which gives me an error “Couldn’t find Post with id=tag”

And a link in the post redirects me to /posts?tag=Test2&view=tag which doesn’t change anything. All my posts are still displayed.

Here’s what I’ve changed so far to try and implement this:

The edited part of my routes.rb:

resources :posts do
collection do
  get :tag
end

end

My post.rb:

acts_as_taggable_on :tags
def self.tag_post_list(page, tag)

  Post.tagged_with(tag).by_date.paginate(:page => params[page], :per_page => 20)

end

Post_Controller.rb:

def index
  @posts = Post.search(params[:search], params[:page])
  @tags = Post.tag_counts_on(:tags)
  if request.xhr?
    render :partial => @posts
  end
end
def tag
  @posts = Post.tagged_with(params[:id])
  @tags = Post.tag_counts_on(:tags)
  render :action => 'index'
end
def show
  @post = Post.find(params[:id])
  @tags = Post.tag_counts_on(:tags)

  respond_to do |format|
    format.html # show.html.erb
    format.json { render json: @post }
  end
end

Posts_helper.rb:

include ActsAsTaggableOn::TagsHelper

Tag cloud in application.html.erb

<% tag_cloud(@tags, %w(css1 css2 css3 css4)) do |tag, css_class| %>
<%= link_to tag.name, { :action => :tag, :id => tag.name }, :class => css_class %>
<% end %>

Tag cloud definition in application_controller.rb

def tag_cloud
  @tags = Post.tag_counts_on(:tags)
end

Links in my posts:

<% for tag in post.tags %>
<%= link_to tag.name, posts_path(:view =>'tag', :tag => tag.name) %>
<% end %>

The error in my console:

Started GET "/posts/tag?id=Test1" for 127.0.0.1 at 2011-11-05 00:35:00 -0700
Processing by PostsController#show as HTML
Parameters: {"id"=>"tag"}
Post Load (0.0ms)  SELECT "posts".* FROM "posts" WHERE "posts"."id" = $1 LIMIT 1  [["id", "tag"]]
Completed 404 Not Found in 3ms

ActiveRecord::RecordNotFound (Couldn't find Post with id=tag): app/controllers/posts_controller.rb:33:in `show'

I’ve searched the internet for the past 5 hours trying to figure this out, but nothing is up to date or entirely relevant.

I get that it is passing “tag” to the show action, but how do I get it to pass the relevant ID and anything else I need to show the correct posts with that tag?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:22:25+00:00Added an answer on May 26, 2026 at 4:22 pm

    Stupid mistake:

    I wasn’t passing paginate to the @posts array in the tag definition.

    @posts = Post.tagged_with(params[:id]).paginate(:page => params[:page], :per_page => 10)
    

    Work’s perfectly. Thanks for the help, you were part of the solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am using JSon response to parse title,date content and thumbnail images and place
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.