Topic: Inheritance managed from controller.

Hi.

I've inheritance to express the relationship between question, questionBool, questionInt, questionAra (Agree, Relevance, Applying). When I create a new question I offer the user the different kinds of questions he could create, but I dont know how to manage the different models.

I've written this:

{{{
    def create
        if request.post? and params[:section_id] and params[:question][:type]
            # This is a HACK and should be fixed.
            case params[:question][:type]
                when "QuestionBool"
                    question = QuestionBool.new(params[:question])
                when "QuestionAra"
                    question = QuestionAra.new(params[:question])
                else
                    flash[:notice] = 'Question was NOT successfully created.'
            end
           
            if question and question.save
                flash[:notice] = 'Question was successfully created.'
                redirect_to :action => "index", :section_id => params[:section_id]
            else
                flash[:notice] = 'Question was NOT successfully created.'
                # Is this a hack? Why have I to type next line?
                @section = Section.find(params[:question][:section_id])
                render :action => "new", :section_id => params[:section_id]
            end
        else
            redirect_to :action => 'index'
        end
    end
}}}

But I know it's ugly and I want to write it correctly.
How can I do it?

Thanks in advance,
VPC