Skip to content

Instantly share code, notes, and snippets.

<% if @category.errors.any? %>
<div id="error_explanation">
<h2>
<%= pluralize(@category.errors.count, "error") %> gør, at ændringen ikke kan gennemføres:
</h2>
<ul>
<% @category.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
@Dysperen
Dysperen / Error
Last active August 29, 2015 14:18
ActiveRecord::UnknownAttributeError in QuizCategoriesController#new
unknown attribute 'quiz_category_id' for QuizQuestion.
Rails.root: F:/Arbejde/Programmering/Workspace/studmed
Application Trace | Framework Trace | Full Trace
app/controllers/quiz_categories_controller.rb:16:in `new'
<% if @category.errors.any? %>
<div id="error_explanation">
<h2>
<%= pluralize(@category.errors.count, "error") %> gør, at ændringen ikke kan gennemføres:
</h2>
<ul>
<% @category.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
ActionController::ParameterMissing in QuizCategoriesController#create
param is missing or the value is empty: quiz_question
Rails.root: F:/Arbejde/Programmering/Workspace/studmed
Application Trace | Framework Trace | Full Trace
app/controllers/quiz_categories_controller.rb:63:in `quiz_question_params'
app/controllers/quiz_categories_controller.rb:21:in `create'
<%= form_for @question do |f| %>
<p>
<%= f.label :question %> <br>
<%= f.text_area :question, placeholder:"Spørgsmål?" %> <br>
</p>
<p>
<%= f.label :answer%> <br>
<%= f.check_box :answer %> <br>
</p>
class QuizQuestionsController < ApplicationController
def index
@questions = QuizQuestion.all
end
def show
@question = QuizQuestion.find(params[:id])
end
<%= link_to 'Tilbage', questions_path %>
<%= form_for @question do |f| %>
<% if @question.errors.any? %>
<div id="error_explanation">
<h2>
<%= pluralize(@question.errors.count, "error") %> gør, at ændringen ikke kan gennemføres:
</h2>
<ul>
<%
if question.correct == true
puts 'true'
else
puts 'false'
end
%>