Skip to content
This repository was archived by the owner on May 28, 2019. It is now read-only.
This repository was archived by the owner on May 28, 2019. It is now read-only.

Getting unknown attribute error #18

@charliemagee

Description

@charliemagee

I've got a real basic Question and Answer project I'm trying to do. I can add answers to my question but as soon as I try to Create Question I get this error:

ActiveRecord::UnknownAttributeError in QuestionsController#create
unknown attribute: question_id

app/controllers/questions_controller.rb:44:in new' app/controllers/questions_controller.rb:44:increate'

The "problem" sections of my controller:

def new
@question = Question.new

respond_to do |format|
  format.html # new.html.erb
  format.json { render json: @question }
end

end

def create
@question = Question.new(params[:question])

respond_to do |format|
  if @question.save
    format.html { redirect_to @question, notice: 'Question was successfully created.' }
    format.json { render json: @question, status: :created, location: @question }
  else
    format.html { render action: "new" }
    format.json { render json: @question.errors, status: :unprocessable_entity }
  end
end

end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions