28 lines
447 B
Ruby
28 lines
447 B
Ruby
#coding=utf-8
|
|
class QuestionsController < ApplicationController
|
|
|
|
def index
|
|
@questions = Question.all
|
|
end
|
|
|
|
def new
|
|
@question = Question.new
|
|
3.times {@question.factors.build}
|
|
end
|
|
|
|
def create
|
|
@question = Question.new(params[:question])
|
|
if @question.save
|
|
redirect_to @question, notice: '新建问题成功'
|
|
else
|
|
render :new
|
|
end
|
|
end
|
|
|
|
def show
|
|
@question = Question.find(params[:id])
|
|
end
|
|
|
|
end
|
|
|