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

  • Home
  • SEARCH
  • 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 6014023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:37:54+00:00 2026-05-23T02:37:54+00:00

I’m basically putting together an app that does a super simple question => answer

  • 0

I’m basically putting together an app that does a super simple question => answer test in an attempt to learn more about rails.

ie:
Question: “What’s your dog’s name?”
Answer: “Doggington”

I have a Question model with two simple attributes:
question:string
correct_answer:string

My struggle here is how do i apply REST principals to this — specifically, when i am checking a user’s input(answer) to see if he got the question right or not.

I’m not sure if i should do something like modify the “show” method (or any other action) to accept values for answer posted to it… and it SEEMS like I should create a new method in my questions_controller called “verify_answer” or something a long those lines.

This breaks REST.

What do you think?

thanks!

  • 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-05-23T02:37:55+00:00Added an answer on May 23, 2026 at 2:37 am

    AnswersController#create should accept the answers. Whether or not this controller actually has a related Answer model is irrelevant. One action should never perform two actions. For instance, if your QuestionsController#show both displays the question, and accepts a :put or :post with the answer to the question then you are breaking basic rails design principals.

    Note that your routes file might very well look like this:

    resources :questions do
      resource :answer
    end
    

    Which will expose the /questions/8/answer route that you can :post to, which will go to AnswersController#create.

    Off the top of my head I’m forgetting the exact name of the helper url method you can use to generate the url. Something like question_answer_path(@my_question).

    This routing file is for rails3, which I assume is what you’re using since there’s no reason to use anything else if you’re starting a new app in my opinion :p

    If you do have an Answer model (maybe you want to store users’ answers and look at them later or aggregate them and come up with statistics and such) then you should change the router to use resources :answer instead of the singular version.

    For more information about routing and some RESTful tips you should visit the Ruby on Rails guide for routing found here: http://guides.rubyonrails.org/routing.html

    I’m on an editing spree! There are times when you might need to add an additional method to your Questions controller that isn’t strictly REST. This isn’t necessarily considered bad practice but just make sure you look at your decisions and find out if you aren’t actually just hiding the existence of another resource. I don’t consider this to be one of those times as explained above 🙂

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to count how many characters a certain string has in PHP, but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.