Forum: Ruby on Rails Okay, what gives? find_by_id is failing.

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Be09addcbb47f2a684fa5c48bac94149?d=identicon&s=25 David Johnson (Guest)
on 2006-04-01 06:52
(Received via mailing list)
This has the look of a "just don't quite get it yet" problem.  I am
using the ActiveRecord.find_by_id method to identify the parent object
(Quiz) to tie to the child object (Question) at create time.

Here is the stdout log: - - [31/Mar/2006:22:43:22 CST] "GET /question/new?
parent_quiz=ff2d7022-be0a-11da-9f01-00400506faf5 HTTP/1.1" 200 806
be0a-11da-9f01-00400506faf5 -> /question/new?parent_quiz=ff2d7022-

Parent           = nil

Parent should be = ff2d7022-be0a-11da-9f01-00400506faf5 - - [31/Mar/2006:22:43:23 CST] "POST /question/create
HTTP/1.1" 500 7042
be0a-11da-9f01-00400506faf5 -> /question/create

Here is the code for question:

class Question < ActiveRecord::Base
  require 'presentations'
  require  'question'

  include UUIDHelper

  has_many :answers, :order => :seq
  belongs_to :presentation, :class_name => "Presentations", :foreign_key
=> :presentation_id
  belongs_to :parent, :class_name => "Quiz"
  acts_as_list :scope => :parent_id, :column => :seq


Here is the code for question_controller:

 def create
# changed because we are instantiating the presentations here
# may not be needed if we instantiate presentations in the initialize,
# but that will require thinking because we already have a use for
# the initialize method.
    @question =
    aParent = Quiz.find_by_id(params[:parent_quiz])
STDOUT.print("Parent           = ",aParent,"\r\n")
    @question.parent = aParent

    @question.presentation =
    @question.presentation.textvalue = @params

STDOUT.print("Parent should be = ",params[:parent_quiz],"\r\n")

-- *** Blows up here ***
STDOUT.print("Parent           = ",,"\r\n")

    if &&
      flash[:notice] = 'Question was successfully created.'
      redirect_to :action => 'list', :parent_quiz => params
[:parent_quiz], :question => params[:question]
      render :action => 'new'
This topic is locked and can not be replied to.