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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:14:57+00:00 2026-05-26T11:14:57+00:00

I have a form used for creating a team (the model is Team). The

  • 0

I have a form used for creating a team (the model is Team).

The form adds members to the team (via the model TeamMember).

Each team works for a company. All users belong to a company.

I currently have a validation on the TeamMember model which prevents a user from becoming a team member when the user works for a different company than the team works for.

Recently, I’ve been asked to modify this functionality, since there are occasions when a team needs to add a member who works for a different company.

My simple validation has now become complicated.

I now need to provide a warning when a proposed team member works for a different company, and give the user a chance to confirm (yes/no) whether this is ok before saving the change.

What is a clean, rails-friendly way to accomplish this? I imagine there is an Ajax solution (maybe a lightbox), but I’m not sure the best way to implement it or whether someone already has a clever Gem/Plugin to handle this situation.

  • 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-26T11:14:57+00:00Added an answer on May 26, 2026 at 11:14 am

    I would use a custom validation for this, as you are now, and add a modifiable attribute to the model that doesn’t save to the db. For example:

    class TeamMember < ActiveRecord::Base
      attr_accessor :user_confirmed
      after_intialize :setup
    
      def setup
        self.user_confirmed = false
      end
    end
    

    What you need to do is add a check in your validation method if self.user_confirmed is false. If it is, in addition to the db relation you described above, make it invalid. Then on your view, add an if statement:

     <% if @team_member.errors[:key_you_use_to_add_to_base].first == "Error Message" %>
        <%= f.label :user_confirmed, "User works for another company, are you sure?" %>
        <%= f.check_box :user_confirmed, {}, "true", "false" %>
     <% end %>
    

    Keep in mind since check_box method uses strings, youll need to convert the result of that attribute in your params hash to a boolean.

    I think that should do it. Note that you may need to adjust the if statement if any other validation errors might be added to the same key.

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

Sidebar

Related Questions

I have a form used for creating a new record of the model Message.
I have a Rails form that is being used for creating and editing a
I have a search form used to query service provisions, which I will call
Once I have programmed GUI with Java and have used Form Layouts. Form layout
I have a form which is used to insert/display and update . In the
We have used Google form, Wufoo form to try to securely capture the info
I have created a form that is used for both adding and editing a
In my c# application i have this small form which is used to set
I created a form using Swing in Java. In the form I have used
I have a report that is used by a windows service and a form

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.