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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:47:12+00:00 2026-05-27T06:47:12+00:00

When submitting an answer I get this error: ActiveRecord::RecordNotFound (Couldn’t find Question with ID=answer):

  • 0

When submitting an answer I get this error:

ActiveRecord::RecordNotFound (Couldn't find Question with ID=answer):
  app/controllers/questions_controller.rb:6:in `show'

From what I understand I either made a error with passing an argument from the form or
didn`t define it correctly in my controller.

Would appreciate some help finding this bug, thanks in advance!

Questions_Controller:

class QuestionsController < ApplicationController
  def index
  end

  def show
      @question = Question.find(params[:id])
      @choices = @question.choices
  end

  def answer
      @choice = Choice.find(:first, :conditions => { :id => params[:id] })
      @answer = Answer.create(:question_id => @choice.question_id, :choice_id => @choice.id)

      if Question.last == @choice.question
        render :action => "thank_you"
      else
        question = Question.find(:first, :conditions => { :position => (@choice.question.position + 1) })
        redirect_to question_path(:id => question.id)
      end
   end
end

views/questions/show.html.erb :

<div data-role="content">
  <div align="center">
    <h3><%= @question.question %></h3>
  </div>
  <br><br>
  <ul data-role="listview">
    <% @choices.each_with_index do |c, i| %>
      <% i = i + 1 %>
      <li data-theme="c">
        <%= link_to "#{i}. #{c.choice}", answer_questions_path(:id => c.id) %>
      </li>
    <% end %>
  </ul>
</div>

::EDIT::

This happens when I try to select a choice & submit an answer while on the first question.

Started GET "/questions/1" for 127.0.0.1 at Thu Dec 01 01:38:36 -0500 2011
  Processing by QuestionsController#show as 
  Parameters: {"id"=>"1"}
  SQL (0.6ms)   SELECT name
 FROM sqlite_master
 WHERE type = 'table' AND NOT name = 'sqlite_sequence'
  Question Load (0.3ms)  SELECT "questions".* FROM "questions" WHERE "questions"."id" = 1 LIMIT 1
  Choice Load (10.8ms)  SELECT "choices".* FROM "choices" WHERE ("choices".question_id = 1)
Rendered questions/show.html.erb within layouts/application (28.8ms)
Completed 200 OK in 424ms (Views: 118.0ms | ActiveRecord: 11.6ms)


Started GET "/questions/answer?id=1" for 127.0.0.1 at Thu Dec 01 01:38:38 -0500 2011
  Processing by QuestionsController#show as 
  Parameters: {"id"=>"answer"}
  Question Load (0.1ms)  SELECT "questions".* FROM "questions" WHERE "questions"."id" = 0 LIMIT 1
Completed   in 10ms

ActiveRecord::RecordNotFound (Couldn't find Question with ID=answer):
  app/controllers/questions_controller.rb:6:in `show'

Hope this helps.

  • 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-27T06:47:13+00:00Added an answer on May 27, 2026 at 6:47 am

    My best guess is that you don’t have a route correctly setup. Assuming that you’re using Rails 3 and you’re using resources, you need to do add the following:

    resources :questions do 
      member do
         put 'answer'
      end
    end
    

    This will create a route like /questions/#{id}/answer.

    Answer is not an HTTP verb, so using resources in your routes will not create a route to your answer action.

    Edit based on comment:

    First, if you’re updating or creating data, you should use put or post. It’s a bad idea to modify data on the server with a get. Secondly, I assume that you would be doing an answer per question. If that is the case, you should do the action on a member, not a collection. Also, in your answer action, you have params[:id]. You won’t get params[:id] if you try to do an action on a collection rather than a member.

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

Sidebar

Related Questions

Apologies if this has been answered before (I couldn't find the answer when I
I started to ask this question and then figured out the answer before submitting
This actually corresponds to my other question but things get more complicated. I have
This seems to be a common question, but I've yet to find a very
Simple question (probably), but I'm buggered if I can find an answer... I have
I couldn't find an answer to my issue while sifting through some Hadoop guides:
I'm sure this would be a simple question to answer but I can't for
So, I submitted an answer to this SO question about redirecting your site ,
When submitting an app to the app store what is the real difference between
Upon submitting this form on my site. It send me to a page that

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.