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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:31:01+00:00 2026-06-11T11:31:01+00:00

I have custom validation in my model very similar to this one: Multifield/range validation

  • 0

I have custom validation in my model very similar to this one:

Multifield/range validation

and the solution offered just works:

errors.add(:base, 'Start date must be before stop date') if self.start > self.stop

Using :base causes just 1 error, and it’s fine because I don’t want two separate errors showing the same here. However, no fields are highlighted, and I need the :start and :stop fields highlighted too, as if I were using :start or :stop in errors.add.

How can I do that?

  • 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-11T11:31:02+00:00Added an answer on June 11, 2026 at 11:31 am

    You should leverage Rails built in mechanisms: they consist in wrapping the form fields containing errors with a div with field_with_error class.

    If this doesn’t suit you:

    • customize it, see Railscast

    • more manual solution, check which errors your instance bears and act accordingly, ie @instance.errors.include? :filed_name. In this scope, don’t add all your errors to base

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

Sidebar

Related Questions

I have a very basic entity model which I'm trying to add custom validation
I have custom validation rule: public function customRule($check) { } Inside this rule I
I have this custom validation attribute for validating a collection. I need to adapt
I have the following validation code processed for my User Model. It works good
I have a custom validation rule on a model that says the user can't
I am trying to implement custom attribute validation, similar to one demonstrated here in
I have a model with a custom DateRange Validation Attribute public class Step1ViewModel {
I have a custom DataAnnotationsModelValidatorProvider for doing model validation in a more dynamic way
In my model I have custom validation method that sends request to the external
I want to apply scope limiter in my custom validation I have this Product

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.