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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T21:45:50+00:00 2026-05-19T21:45:50+00:00

model: validates :name, :presence => true validates :year, :presence => true validates :description, :presence

  • 0

model:

validates :name, :presence => true
validates :year, :presence => true
validates :description, :presence => true

when submitting the form containing these fields, leaving the text boxes blank on purpose, instead of getting the Rails error messaging, I get the following exception thrown:

NoMethodError

You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each

Any thoughts on why this may occur would be greatly appreciated.

  • 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-19T21:45:51+00:00Added an answer on May 19, 2026 at 9:45 pm

    A stab in the dark would be that its not your validations throwing the error message. My first instinct is that its the error view code (if you are looping through the errors the nil is possibly in there). Its also possible its an error in the controller but I would have to see the first couple lines of the backtrace to make a more informed guess.

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

Sidebar

Related Questions

I have a rails model that validates uniqueness of 2 form values. If these
I've created a simple Project model with four attributes: Project name:string description:text complete:boolean user_id:integer
I have this model: class Tag < ActiveRecord::Base # Validations validates :name, :presence =>
In my user model, I have an attribute called nickname and validates as such:
class Tag(models.Model): name = models.CharField(maxlength=100) class Blog(models.Model): name = models.CharField(maxlength=100) tags = models.ManyToManyField(Tag) Simple
What is the difference between validates :presence and validates_presence_of ? Looking through ActiveModel it
I followed the tutorial Create a model through text field (Railscast #57) which works
In my model I have: validate :my_custom_validation def my_custom_validation errors.add_to_base(error message) if condition.exists? end
For example, if I have a user model and I need to validate login
My model layer is being used by a handful of different projects and I'd

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.