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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:44:19+00:00 2026-06-09T10:44:19+00:00

I’m trying to ensure a boolean value in my Rails model cannot be set

  • 0

I’m trying to ensure a boolean value in my Rails model cannot be set to nil. Here’s my model:

class Response < ActiveRecord::Base
  attr_accessible :attending

  # validations
  validates :attending, :allow_nil => false
end

When I try to run my specs, I get the following excpetion:

/Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activemodel-3.2.7/lib/active_model/validations/validates.rb:86:in `validates': You need to supply at least one validation (ArgumentError)
    from /Users/helixed/Dropbox/Development/current/rsvp/app/models/response.rb:5:in `<class:Response>'
    from /Users/helixed/Dropbox/Development/current/rsvp/app/models/response.rb:1:in `<top (required)>'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/dependencies.rb:251:in `require'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/dependencies.rb:251:in `block in require'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/dependencies.rb:251:in `require'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/dependencies.rb:359:in `require_or_load'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/dependencies.rb:502:in `load_missing_constant'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/dependencies.rb:192:in `block in const_missing'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/dependencies.rb:190:in `each'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/dependencies.rb:190:in `const_missing'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/inflector/methods.rb:230:in `block in constantize'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/inflector/methods.rb:229:in `each'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/inflector/methods.rb:229:in `constantize'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/inflector/methods.rb:260:in `safe_constantize'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/core_ext/string/inflections.rb:66:in `safe_constantize'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.7/lib/action_controller/metal/params_wrapper.rb:152:in `_default_wrap_model'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.7/lib/action_controller/metal/params_wrapper.rb:169:in `_set_wrapper_defaults'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.7/lib/action_controller/metal/params_wrapper.rb:133:in `inherited'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.7/lib/abstract_controller/railties/routes_helpers.rb:7:in `block (2 levels) in with'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/actionpack-3.2.7/lib/action_controller/railties/paths.rb:7:in `block (2 levels) in with'
    from /Users/helixed/Dropbox/Development/current/rsvp/app/controllers/responses_controller.rb:1:in `<top (required)>'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/dependencies.rb:251:in `require'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/dependencies.rb:251:in `block in require'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/dependencies.rb:251:in `require'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/dependencies.rb:359:in `require_or_load'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/dependencies.rb:313:in `depend_on'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activesupport-3.2.7/lib/active_support/dependencies.rb:225:in `require_dependency'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.7/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.7/lib/rails/engine.rb:438:in `each'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.7/lib/rails/engine.rb:438:in `block in eager_load!'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.7/lib/rails/engine.rb:436:in `each'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.7/lib/rails/engine.rb:436:in `eager_load!'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.7/lib/rails/application/finisher.rb:53:in `block in <module:Finisher>'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.7/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.7/lib/rails/initializable.rb:30:in `run'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.7/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.7/lib/rails/initializable.rb:54:in `each'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.7/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.7/lib/rails/application.rb:136:in `initialize!'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.7/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/helixed/Dropbox/Development/current/rsvp/config/environment.rb:5:in `<top (required)>'
    from /Users/helixed/Dropbox/Development/current/rsvp/spec/spec_helper.rb:3:in `require'
    from /Users/helixed/Dropbox/Development/current/rsvp/spec/spec_helper.rb:3:in `<top (required)>'
    from /Users/helixed/Dropbox/Development/current/rsvp/spec/controllers/responses_controller_spec.rb:1:in `require'
    from /Users/helixed/Dropbox/Development/current/rsvp/spec/controllers/responses_controller_spec.rb:1:in `<top (required)>'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `block in load_spec_files'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `map'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load_spec_files'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:in `run'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in `run'
    from /Users/helixed/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in `block in autorun'
  • 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-09T10:44:21+00:00Added an answer on June 9, 2026 at 10:44 am

    :allow_nil should come as an option to some validation. You used it on its own which is not the correct way to use it.

    If you want to validate :attending is true you can do it the following way:

    validates :attending, :acceptance => { :accept => true }, :allow_nil => false
    

    UPDATE:

    In order to validate :attending is boolean (either true or false) you can use:

     validates :attending, :inclusion => { :in => [true, false] }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to render a haml file in a javascript response like so:
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.