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 8883965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:56:55+00:00 2026-06-14T20:56:55+00:00

In an edit.html.erb file I have the code <%= form_for @submission do |f| %>

  • 0

In an edit.html.erb file I have the code

<%= form_for @submission do |f| %>
  <%= f.fields_for :submitted_answers do |answer| %>
     <%= answer.label :question_id %>
     <%= answer.number_field :question_id %>
  <% end %>
<% end %>

This shows me a number field that has the current value of question_id and allows me to change it. Now I just want to display that value and not let anyone change it. How would I get that value?

If I say

<% @question = :question_id %>

question just equals a string: “question_id”

  • 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-14T20:56:56+00:00Added an answer on June 14, 2026 at 8:56 pm

    You seem to be mistaking what’s going on here. A symbol is an object that’s similar to a string, but stored differently in memory and with a different syntax. When you pass a symbol to many methods in Ruby, they’re used as references to methods. In this case, the :question_id symbol being passed as an argument to the number_field helper method, it’s subsequently being called on the form object (that is, what is likely to be an ActiveRecord model).

    Long story short, answer, a form builder, gets the question id from the model you passed into your form_for call. To display the value, you can do the same thing by calling the method directly, i.e.:

    <%= @submission.question_id %>
    

    However, since you’re iterating over these using fields_for, you can instead get to the object the form builder is referencing by calling object:

    <%= answer.object.question_id %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my Ruby on Rails code, I have the following edit.html.erb file for tasks:
I have this code in my index.html.erb file in my project: <h1>Listing businesses</h1> <table>
I have this code to render a file into another file: $(#edit_topics_link).click(function(e){ e.preventDefault(); $(.topic_form).load(/topic_form.html.erb);
I have the following form in my edit.html.erb page <%= form_for(@device) do |f| %>
Here's what I have in my users/edit.html/erb <%= form_for(resource, :as => resource_name, :url =>
I have a js.erb file with the following code but I can't seem to
In my global.css file which is loaded by application.html.erb , I have the following
Ryan Bates' nifty_scaffolding, for example, does this edit.html.erb <%= render :partial => 'form' %>
I have a line of php code that looks like this: echo <script>$('#edit_errors').html('<h3><em>Please Correct
EDIT 2: I have just realised that my HTML is only displaying the artist

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.