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 5945519
In Process

The Archive Base Latest Questions

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

I receive this error when I type an existing topic into the topic field

  • 0

I receive this error when I type an existing topic into the topic field of my form:

Started GET "/posts/autocomplete_topic_name?term=test" for 127.0.0.1 at 2011-05-21 10:51:19 -0700
  Processing by PostsController#show as JSON
  Parameters: {"term"=>"test", "id"=>"autocomplete_topic_name"}
  Post Load (0.2ms)  SELECT "posts".* FROM "posts" WHERE "posts"."id" = 0 LIMIT 1
Completed   in 28ms

ActiveRecord::RecordNotFound (Couldn't find Post with ID=autocomplete_topic_name):
  app/controllers/posts_controller.rb:9:in `show'

Rendered /home/dude/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.6/lib/action_dispatch/middleware/templates/rescues/_trace.erb (2.5ms)
Rendered /home/dude/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.6/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (4.2ms)
Rendered /home/dude/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.6/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (14.2ms)

The topics “test” and “testing” exist.

models:

class Topic < ActiveRecord::Base
  has_many        :posts
  validates       :name, :presence => true,
  attr_accessible :name, :post_id
end

class Post < ActiveRecord::Base
  belongs_to :topic
  accepts_nested_attributes_for :topic
  attr_accessible :name, :title, :content, :topic, :topic_attributes
end

view:

/posts/new renders only this form: (uses simple_form)

<%= simple_form_for :post, :url => { :controller => :posts, :action => "create" } do |f| %>
  <h1>Create a Post</h1>
  <%= f.input :name, :label => false, :placeholder => "Name (optional)", :required => false %>
  <%= f.input :title, :label => false, :placeholder => "Title" %>
  <%= f.input :content, :label => false, :placeholder => "Content", :as => :text %>
  <%= f.simple_fields_for :topic do |topic_form| %>
    <%= topic_form.input :name, :label => false, :placeholder => "Topic", :url => autocomplete_topic_name_path, :as => :autocomplete %>
  <% end %>
  <%= raw recaptcha_tags -%>
  <%= f.button :submit, "Post" %>  
<% end %>

controller:

class PostsController < ApplicationController
  autocomplete :topic, :name, :full => true
  respond_to :html, :js, :xml

  def new
    @post = Post.new
  end

  def create
    topic_name = params[:post].delete(:topic)
    @topic = Topic.find_or_create_by_name(topic_name)
    @post = Post.new(params[:post])
    @post.topic = @topic
    respond_to do |format|
      if verify_recaptcha(:model => @post) && @post.save
        format.html { redirect_to(@post, :notice => 'Post was successfully created.') }
      else
        flash.delete(:recaptcha_error)
        flash.now[:error] = "Incorrect word verification. Are you sure you\'re human?"
        format.html { render :action => "new" }
      end
    end
  end
end

Line 9 of the Posts controller is:

 @post = Post.find(params[:id])

in the posts#show

routes.rb:

MyApp::Application.routes.draw do
  root :to => "posts#index"
  resources :topics
  resources :posts
  resources :comments
  match "posts/autocomplete_topic_name", :as => "autocomplete_topic_name"
end

Here’s my gemfile:

gem 'rails', '3.0.6'
gem 'sqlite3'

gem 'ancestry'
gem 'jquery-rails', '>= 1.0.3'
gem 'kaminari'
gem 'nifty-generators'
gem 'rdiscount'
gem 'rails3-jquery-autocomplete'
gem 'recaptcha', :require => 'recaptcha/rails'
gem 'simple_form'

and schema:

create_table "posts", :force => true do |t|
  t.string   "name"
  t.string   "title"
  t.text     "content"
  t.integer  "topic_id"
  t.datetime "created_at"
  t.datetime "updated_at"
end

create_table "topics", :force => true do |t|
  t.string   "name"
  t.datetime "created_at"
  t.datetime "updated_at"
end

Thanks for taking a look.

  • 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-22T16:41:36+00:00Added an answer on May 22, 2026 at 4:41 pm

    Within your routes file, try moving the “match ‘posts/…'” line before “resources :posts”.

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

Sidebar

Related Questions

What do you think why I receive this error when I type something on
I receive this error by running the function below. TypeError: Error #1034: Type Coercion
I receive this error when trying to run the client. The type 'StringPro.IMyString' is
I'm escaping all the string parameters I receive from a php form like this:
Every time I do a ConfigurationManager.GetSection(registeredPlugIns) for this custom section I receive this error:
When I try to compile the following code I receive an error: Type error
I'm trying to add stf.PrimarySchoolID (an integer) into this existing query. I have a
My code is like below, when I compile it , I receive this error
I'm trying to use WCF Data Service with Subsonic, but ran into this error
I'm using subclipse in Flex Builder 3, and recently received this error when trying

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.