Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8760303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:00:43+00:00 2026-06-13T15:00:43+00:00

I’m built app which allow users create questions are type: True/False, Single and Multiple

  • 0

I’m built app which allow users create questions are type: True/False, Single and Multiple Choice. So, I have created some models:

class QuestionType < ActiveRecord::Base
  attr_accessible :name, :shorcut
end

class Question < ActiveRecord::Base
  attr_accessible :content, :mark, :topic_id, :question_type_id, :answers_attributes
  belongs_to :topic
  belongs_to :user
  belongs_to :question_type
  has_many :answers, dependent: :destroy
  accepts_nested_attributes_for :answers
end

class Answer < ActiveRecord::Base
  attr_accessible :content, :question_id, :correct

  belongs_to :question
end

Now i would to build an index page of questions, have 3 link to add question for 3 type of question, when users click a link, they will go to page to create question and page will have appropriate form for type of that question. In Question controller, i want to store question type id to save to question.
I think the addresses like this:

http://example.com/questions/index : Index page will have 3 link to create question.

http://example.com/question_types/1/questions/new: Will render partial form for True/False question

http://example.com/question_types/2/questions/new: Will render partial form for Single choice question

http://example.com/question_types/1/questions/new: Will render partial form for Multiple choice question

I think i have to put nested resources in my routes with question type and question model to have above type of link, but i don’t know how to build view and separate like above. please help me or give me an idea, better way to do it 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T15:00:44+00:00Added an answer on June 13, 2026 at 3:00 pm

    By my understanding of your question, this might solve your question:

    in your app/views/questions/new.html.erb you can do it like this:

    
    
        case params[:question_type_id]
        when 1
        render :partial=>"/questions/new_true_false_question"
        when 2
        render :partial=>"/questions/new_single"
        when 3
        render :partial=>"/questions/new_multi"
        end
    
    

    and then create the three partials as refered abow or in whatever names you like.

    OR you can do it in the controller by chaning render :partial to render :template.

    🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from
I'm trying to create an if statement in PHP that prevents a single post
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.