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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:07:48+00:00 2026-05-31T05:07:48+00:00

Here’s the code: = form_for @form do |f| = f.fields_for :questions do |q| %p

  • 0

Here’s the code:

= form_for @form do |f|
  = f.fields_for :questions do |q|
    %p
      = q.object.content
      = q.fields_for :answers do |a|
        %p= a.text_area :content

What the name attribute on the text_area should be form[questions_attributes][0][answer_attribute][content] but it’s showing. form[questions_attributes][0][answers][content].

Here’s my models.

# answer.rb
  belongs_to :question

# question.rb
  has_one :answer
  accepts_nested_attributes_for :answer

# form.rb
  has_many :questions, :order => 'position ASC'
  accepts_nested_attributes_for :questions

So what I’m getting in the log is WARNING: Can't mass-assign protected attributes: answers

Any help would be greatly appreciated. Thanks!

update

here’s the log so you can see what’s being passed:

Started POST "/forms/16" for 127.0.0.1 at Fri Mar 09 16:53:58 -0500 2012
  Processing by FormsController#update as HTML
  Parameters: {"commit"=>"Update Form", "utf8"=>"✓", "id"=>"16", "authenticity_token"=>"mcRJP8XgvE0Cl1JsPryER47+Hbx5DwpEveR1m0R7S6k=", "form"=>{"opportunity_id"=>"1", "questions_attributes"=>{"0"=>{"id"=>"101", "answers"=>{"content"=>"asdfasdf"}}, "1"=>{"id"=>"102", "answers"=>{"content"=>"asdfasdf"}}, "2"=>{"id"=>"103", "answers"=>{"content"=>"asdfasdf"}}, "3"=>{"id"=>"104", "answers"=>{"content"=>""}}, "4"=>{"id"=>"105", "answers"=>{"content"=>""}}, "5"=>{"id"=>"106", "answers"=>{"content"=>""}}, "6"=>{"id"=>"107", "answers"=>{"content"=>""}}, "7"=>{"id"=>"108", "answers"=>{"content"=>""}}}, "status"=>"Not Reviewed", "current_step"=>"", "account_id"=>"1"}}
  SQL (0.8ms)   SELECT name
 FROM sqlite_master
 WHERE type = 'table' AND NOT name = 'sqlite_sequence'

  Form Load (0.2ms)  SELECT "forms".* FROM "forms" WHERE "forms"."id" = 16 LIMIT 1
  Question Load (1.1ms)  SELECT "questions".* FROM "questions" WHERE "questions"."id" IN (101, 102, 103, 104, 105, 106, 107, 108) AND ("questions".form_id = 16) ORDER BY position ASC
WARNING: Can't mass-assign protected attributes: answers
WARNING: Can't mass-assign protected attributes: answers
WARNING: Can't mass-assign protected attributes: answers
WARNING: Can't mass-assign protected attributes: answers
WARNING: Can't mass-assign protected attributes: answers
WARNING: Can't mass-assign protected attributes: answers
WARNING: Can't mass-assign protected attributes: answers
WARNING: Can't mass-assign protected attributes: answers
Redirected to http://vol.dev/forms/16
Completed 302 Found in 208ms

Update 2

When I add answers to attr_accessible in question.rb I get ActiveRecord::UnknownAttributeError (unknown attribute: answers)

  • 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-31T05:07:48+00:00Added an answer on May 31, 2026 at 5:07 am

    I left everything in my models as is but I did this to the form:

     = f.fields_for :questions do |q|
        = q.fields_for :answer, q.object.answer do |a|
          = a.hidden_field :question_id, :value => q.object.id
          = a.hidden_field :form_id, :value => @form.id
          %p
            = a.label :content, q.object.content
            %br
            = a.text_area :content
    

    And it works perfectly. If there’s any refining or anything feel free to comment on this.

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

Sidebar

Related Questions

Here is my code, which takes two version identifiers in the form 1, 5,
Here is some simple code: DIR* pd = opendir(xxxx); struct dirent *cur; while (cur
Here's the code in AlertTableView: - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ NSInteger index = 12345; NSLog(@AlertTableView:
Here is an example: I write html code inside of textarea, then I swap
here is my configuration: http://domain.com (obviously fictitious name...) hosted on a server running Apache
Here is the css: #content ul { font-size: 12px; } I am trying this:
Here's a problem I ran into recently. I have attributes strings of the form
Here is my code...I have two dimensional matrices A,B. I want to develop the
Here is my code sample, let me know if it can be further improved?
Here is my code (Say we have a single button on the page that

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.