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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:17:41+00:00 2026-06-05T14:17:41+00:00

I am quite new to both programming and ruby on rails. I have followed

  • 0

I am quite new to both programming and ruby on rails. I have followed http://ruby.railstutorial.org/ and then i have started to watch episodes from http://railscasts.com. What i am trying to do is that “Handling multiple models in a single form”. Below you will see my models and their assosications and also the view of form that i am trying to get info from users.

My modelling is that;

There are employers, employers have interviews and interviews have questions.

Customquestion model:

class Customquestion < ActiveRecord::Base
  attr_accessible :content
  belongs_to :interview

  validates :content, length: {maximum: 300}
  validates :interview_id, presence: true
end

Interview model:

class Interview < ActiveRecord::Base
  attr_accessible :title, :welcome_message
  belongs_to :employer
  has_many :customquestions, dependent: :destroy
  accepts_nested_attributes_for :customquestions

  validates :title, presence: true, length: { maximum: 150 }
  validates :welcome_message, presence: true, length: { maximum: 600 }
  validates :employer_id, presence: true
  default_scope order: 'interviews.created_at DESC'
end

Form to create new interview;

<%= provide(:title, 'Create a new interview') %>
<h1>Create New Interview</h1>

<div class="row">
  <div class="span6 offset3">
    <%= form_for(@interview) do |f| %>
    <%= render 'shared/error_messages_interviews' %>

      <%= f.label :title, "Tıtle for Interview" %>
      <%= f.text_field :title %>

      <%= f.label :welcome_message, "Welcome Message for Candidates" %>
      <%= f.text_area :welcome_message, rows: 3 %>

      <%= f.fields_for :customquestions do |builder| %>
        <%= builder.label :content, "Question" %><br />
        <%= builder.text_area :content, :rows => 3 %>
      <% end %>
      <%= f.submit "Create Interview", class: "btn btn-large btn-primary" %>
    <% end %>
  </div>
</div>

When i fill the form with required information and submit it, i get following error;

Can't mass-assign protected attributes: customquestions_attributes

Application Trace | Framework Trace | Full Trace
app/controllers/interviews_controller.rb:5:in `create'
Request

Parameters:

{"utf8"=>"✓",
 "authenticity_token"=>"cJuBNzehDbb5A1Zb14BjBfz1eOsjBCDzGhYKT7q6A0k=",
 "interview"=>{"title"=>"",
 "welcome_message"=>"",
 "customquestions_attributes"=>{"0"=>{"content"=>""}}},
 "commit"=>"Create Interview"}

I hope that i have provided enough information for you guys to understand what is problem with that case.

Thank you in advance

  • 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-05T14:17:44+00:00Added an answer on June 5, 2026 at 2:17 pm

    Just follow what is written in the error message: try to add attr_accessible :customquestions_attributes to Interview model:

    class Interview < ActiveRecord::Base
       attr_accessible :title, :welcome_message, :customquestions_attributes
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm quite new to javascript programming and got stuck in this problem: I have
I'm currently using Rails v2.3.5 at work and I'm quite new both to the
I'm quite new to php and have been reading Larry Ullman book to develop
I am quite new to C++, but have worked with C# for years, however
Hey guys :) I am quite new to stack overflow and iPhone programming. I
I am quite new to Rails and I can't seem to get my head
I am quite new to the HTTP set of classes. I am trying to
I'm quite new to matlab, but I know how to do both for loops
first i have to say i am quite new with spring and hibernate. now
I am quite new to socket programming. I was trying to make p2p communication

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.