Я получаю эту ошибку после отправки формы: (в индексной странице)неопределенного метода `model_name_question» для # .. Rails 4
<%= simple_form_for(@quiz, html: {class: 'form-vertical' }) do |f| %>
<%= render 'shared/error_messages_question' %>
<%= f.input_field :content, :rows => 3, :style => "width:80%", :placeholder => "enter your question." %>
<%= f.button :submit %>
<% end %>
У меня есть question
модель:
class Question < ActiveRecord::Base
validates :question, presence: true
belongs_to :category
belongs_to :questioner
end
и вопросы:
class QuestionsController < ApplicationController
def index
@quiz = Question.new
@questioner = Questioner.new
end
def new
@quiz = Question.new(quiz_params)
end
def show
@quiz = Question.find(params[:id])
end
def edit
@quiz = find(params[:id])
raise "Question Not edited!" unless @quiz
end
def create
@quiz = Question.new(quiz_params)
if @quiz.save
flash[:success] = 'You have successfully posted the questions!'
redirect_to questions_path
else
flash[:error] = "Please review the problems below."
# render 'new'
redirect_to questions_path
end
end
private
def quiz_params
params.require(:question).permit(:content, :answered, :questioner_id, :category_id)
end
end
Что может быть проблемой? на сервере рельсы У меня есть это:
Completed 500 Internal Server Error in 5ms
NoMethodError - undefined method `question' for #<Question:0x0000000433dfc0>:
activemodel (4.0.2) lib/active_model/attribute_methods.rb:439:in `method_missing'
спасибо, что заметьте человек. Я этого не видел. – ben