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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:28:30+00:00 2026-05-26T10:28:30+00:00

Alright. First off, I am new to Rails and this is the first project

  • 0

Alright. First off, I am new to Rails and this is the first project I am trying to build from scratch.

I have 2 models: Course and Question. I want to be able to add Questions to a specific Course, so Course is the parent model of Question. (Course has_many :questions and Question belongs_to :course)

From courses/show I render a partial:

<%= render 'questions/form', :question => @course.questions.build %>

and the partial questions/_form:

<%= form_for(question) do |f| %>
  <div class="field">
    <%= f.text_field :content %>
    <%= f.hidden_field :course_id %>
  </div>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

and here is the create function:

def create
    @course = Course.find(params[:question][:course_id])
    question = @course.questions.build      
    if question.save
      redirect_to @course
    end   
end

But in my console I get the following output:

Started POST "/questions" for 127.0.0.1 at 2011-10-27 19:06:25 -0400
  Processing by QuestionsController#create as HTML
  Parameters: {"utf8"=>"✓",         "authenticity_token"=>"negkm0uXBez8sisXl3pFVgfvhcDkixFPiMjzM68mNVU=", "question"=>{"content"=>"hallo", "course_id"=>"2"}, "commit"=>"Create Question"}
  Course Load (0.3ms)  SELECT "courses".* FROM "courses" WHERE "courses"."id" = $1 LIMIT 1  [["id", "2"]]
  (0.3ms)  BEGIN
  SQL (0.5ms)  INSERT INTO "questions" ("content", "course_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"  [["content", nil], ["course_id", 2], ["created_at", Thu, 27 Oct 2011 23:06:25 UTC +00:00], ["updated_at", Thu, 27 Oct 2011 23:06:25 UTC +00:00]]
  (1.6ms)  COMMIT

What I don’t understand is that the Parameters include “content”=>”hallo”, but the value inserted into my table is nil…

I am fairly sure that I made a jumbled up mess because this is the product of an hour or trial and error, if anyone has a small change I should make or even a completely different way to achieve the same goal, that would be much appreciated.

  • 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-26T10:28:31+00:00Added an answer on May 26, 2026 at 10:28 am

    You are looking up a course with a course_id, if one exists, but you make no further references to the params hash-like object, nor the content parameter within params — so it can never be saved. Try:

    question = @course.questions.build(params[:content])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright this is my first day with JQuery so have fun with these functions
Alright I created some custom classes for my project sourced from this tutorial ,
Alright, I have some weird behavior and this question goes to the people out
Alright, this is a really quick question: why does this first block of code
Alrighty then, howdy first off; quick question I have a form that has multiple
Alright I have way to much time invested in this. I am new to
Alright, first off I'm not quite sure how to phrase my problem. This could
Alright, I'm at my wit's end on this issue. First, backstory. I'm working on
Alright so I have no idea how to even begin doing this But basically
Alright, so I got this code for gluLookAt: lookAt = new Vector3f(-player.pos.x, -player.pos.y, -player.pos.z);

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.