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

  • Home
  • SEARCH
  • 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 4531148
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T13:52:34+00:00 2026-05-21T13:52:34+00:00

In my project, I altered the registration form in Devise to add an :agree

  • 0

In my project, I altered the registration form in Devise to add an :agree option via an accessor (user must accept terms of service to register, etc). If they don’t agree, it doesn’t validate.

That caused a problem when a user tried to edit their account information as it seeked out the :agree validation, but I was able to add an ‘unless’ clause and added another accessor called :signed_in that is defined in the controller (I couldn’t figure out how to get the model to determine if the user was signed in or not, devise’s helpers wouldn’t work for me in it). The relevant portions of my User model and users_controller look like…

user.rb

validates :agree, :term_agreement => TRUE, :unless => :signed_in

users_controller.rb

def update
   @user = User.find(params[:id])

   if user_signed_in?
     @user.signed_in = params[:user]
   end

  [...]
end

So, it all works fine…the “agree” validation overrides when a user is already signed in. However, I have to figure out the best way to override another scenario…when a user resets their password and needs to change it.

I was testing user accounts and tried to reset my password on one account, however I was hit with the :agree validation…now I have to figure out a way to override that. I noticed the Change your password form has a hidden field value of :reset_password_token, however I tried :unless => :reset_password_token but it wouldn’t work.

So what is the best way of accomplishing this? On top of that, how can I have an either / or condition (unless :signed_in or :reset_password, etc) for that :unless clause?

  • 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-21T13:52:35+00:00Added an answer on May 21, 2026 at 1:52 pm

    So, you need to validate the acceptance of terms when the record is created?

    class User < ActiveRecord::Base
      validates :agree, :acceptance => true, :on => :create
    end
    

    :on => :create will only perform that validation when the record is being created—much like Brandon’s answer, but without redundant code.

    This will also obviate the need for your controllers to worry about if a user is signed in or not.

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

Sidebar

Related Questions

I altered a bunch of project files in our solution, to add a reference
I'm trying to add a service reference to my silverlight project from a file
Project: http://design.vitalbmx.com/fave/news.html When I click Add to favorites button (under main pic), in Chrome
I have a project where the Model can be altered from one of many
I have altered the src/templates/scaffolding/renderEditor.template file in a grails project, in order to insert,
We have an XML configuration file in our project that needs to be altered
Project layout: /project_a /shared /project_b /shared /shared project_a and project_b both need to contain
My project consists of an app that links to two static libraries. Each of
The project that I am working on (Node.js) implies lots of operations with the
The project currently has a UIviewController called Dashboard that acts as the main view

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.