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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:59:04+00:00 2026-05-24T12:59:04+00:00

I am using ruby 1.9.2-p180, rails 3.0.7. I have used validates_acceptance_of since the user

  • 0

I am using ruby 1.9.2-p180, rails 3.0.7. I have used validates_acceptance_of since the user has to agree to our terms and conditions. We don’t have a column for this, but I understand that “If the database column does not exist, the terms_of_service attribute is entirely virtual. ” from http://ar.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M000082

Anyway, I double checked this by smoke testing the app manually and I see from the logs that the record is still inserted into the db, which is weird because upon submitting the form, I am redirected back to the form with the error: “Must agree to terms and conditions”(which made me think it worked before)

Am I doing something wrong here?

_form.haml:

%label.checkbox-label{:for => "operator_terms_and_conditions"}
  = f.check_box :terms_and_conditions
  I agree to 
  = link_to "Terms and Conditions", operator_terms_path, :target => "_blank"

operators_controller:

def create
  user_params = params[:operator][:user]
  user_params.merge!(:login => user_params[:email])
  @password = params[:operator][:user][:password]

  Operator.transaction do # don't save User if operator is invalid
    @operator = Operator.create(params[:operator])
  end

  respond_to do |format|
    unless @operator.new_record?
      UserMailer.operator_confirmation_email(@operator, @password).deliver
      UserMailer.operator_registration_admin_notification_email(@operator).deliver

      UserSession.create(@operator.user)
      format.html {redirect_to new_operator_aircraft_path}
    else
      format.html { render :action => "new" }
    end
  end

end

and in the model:

validates_acceptance_of :terms_and_conditions
  • 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-24T12:59:04+00:00Added an answer on May 24, 2026 at 12:59 pm

    Found the answer. The problem was not with validates_acceptance_of but rather with how I was saving the data. When an operator was created, a user was also created that was tied to it and it was this user that was being inserted into the db.

    This happens because although the operator was being rolled back(because it wasn’t valid) the user was still created(because it was not in a transaction).

    I solved this by using nested_transactions:

    operator model:

    ...
    User.transaction(:requires_new => true) do
      create_user
      raise ActiveRecord::Rollback unless self.valid?
    end
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using Ruby on Rails 2.3.2, since I already created Scaffold for Story, so instead
Using Ruby 1.8.7-p358, Rails 3.0.12, gem responder, gem simple-form; jquery_ujs.js I have a form
Using Ruby on Rails 3, I have a page with a list of comments
Using Ruby 1.9.2, Rails 3.1. I have the following code: # review.rb def calculate_rating(reviewable)
I'm using Ruby 1.9.2-p180 on Ubuntu 12.04. I don't understand why the following code
our site is written using Ruby on Rails. We are using coffeescript & SCSS.
Using Ruby 1.8.6 & Rails 1.2. Models: Job , JobExtraStop : class JobExtraStop <
Using Ruby on Rails. I'm trying to sort a query by number (saved as
Using Ruby (1.8.7) and Rails (2.3.8) doing myObject.attributes gives you a hash of attribute
Using Ruby and Haml, I have a property which is cost. I believe (im

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.