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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:10:59+00:00 2026-06-16T12:10:59+00:00

I have a multi-model form and I cannot seem to capture the errors related

  • 0

I have a multi-model form and I cannot seem to capture the errors related to the nested models. This is the hierarchy of the form Project->Team->Roles->Role_skill_relationship. I am able to capture errors related the project model instance @project but I have been unsuccessful at capturing validations related to the Role and Skills models. The errors are directly returned in the browser page rather than redirecting and flashing to the screen. One example of an error if I intentionally fill out a role portion of the form incorrectly is

NoMethodError in Roles#create

Showing
C:/Users/Dstile/Documents/GitHub/creunity_app/app/views/skills/_form.html.erb
where line #8 raised:

undefined method `map’ for nil:NilClass Extracted source (around line #8)

7: <%= skill_form.label :skill %>

8: <%= skill_form.collection_select :skill_id, @skills, :id, :name, :prompt => “Select a > skill” %>

Here is a portion of the code

<%= render 'shared/project_error_messages' %>

    <%= project_form.label :title %>
    <%= project_form.text_field :title %>

    <%= project_form.label :category, "Category" %>
    <%= project_form.select(:category, Project::CATEGORY_TYPES) %>

    <%= project_form.label :description %>
    <%= project_form.text_area :description %>

    <%= project_form.label :goal_1, "Goal 1:" %>
    <%= project_form.text_field :goal_1 %>

    <h2>Your Team</h2>
    <%= project_form.fields_for :team do |f| %>
      <%= render 'teams/form', :team_form => f %>
    <% end %>`

Here is the error render code

'<% if @project.errors.any? %>
  <div id="error_explanation">
    <div class="alert alert-error">
      The form contains <%= pluralize(@project.errors.count, "error") %>.
    </div>
    <ul>
    <% @project.errors.full_messages.each do |msg| %>
      <li>* <%= msg %></li>
    <% end %>
    </ul>
  </div>
<% end %>'

The role form is nested within the team form in the same manner team is nested in project. From all of the other threads I have read my understanding is that the errors for project and all of its children models (team, roles, role_skill_relationships) should be captured by the @parent object.

Is there a config setting or piece of code I am missing that should force the browser to ignore the errors? My thinking is that the errors may be in @project but that this process is interrupted.

  • 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-16T12:11:02+00:00Added an answer on June 16, 2026 at 12:11 pm

    It appears @skills has not been set. #collection_select runs #map on the passed-in collection (@skills in this case), and will show that error if the collection is nil (which is the default value for undefined instance variables).

    Remember that, in the case of validation errors, the #create method in your controller will simply be rendering a template – it does not run the corresponding action method for that template. So if you’re defining @skills in your #new action, then you need to also define it in your #create action (or, better yet, in a before_filter).

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

Sidebar

Related Questions

I have a three-level multi-nested form in Rails. The setup is like this: Projects
I have some models and I want to generate a multi-selection form from this
I have three models presented in a multi-model form. class Parent < ActiveRecord::Base has_many
I am following the Rails guide for doing multi-model nested form. I have 2
I have a multi-model form submission that appends all model errors into a single
I have a multi-step order form built in this manner: Step 1: Choose category
I have a multi model with different OneToOne relationships from various models to a
I cannot seem to get a nested form to generate in a rails view
I have a multi step form which uses one model object and I need
I have 2 multi-table inherited models like these: class Post(models.Model): title = models.CharField(max_length=100, blank=True,

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.