Skip to content

Rails' validate method and ajax #31

@mrrooijen

Description

@mrrooijen

Hi.

I was wondering, as it wasn't clear to me, whether validatious-on-rails supports the built-in custom Rails "validate" method? I know that the validates_uniqueness_of method does an ajax call, but is there a way to create a custom validate method that gets checked through ajax?

Example:

class User < ActiveRecord::Base
  validate :invitation, :client_side => false
  def invitation
    unless self.find_by_email_and_invitation(email, invitation_code)
      # if the specified email and invitation code do not match, add an error to the field
      errors.add(:invitation, "This invitation is invalid.")
    end
  end
end

Basically something like that, where you just call the "validate" method to create a new custom validation that (I would assume) will always be called through an ajax call..

Is this already possible? Will it be possible in later versions?

I believe I did read something about "Custom Validations" but I wasn't sure what you meant by that in the README so I wanted to verify that I'm not missing anything here.

Anyway, I love this tool regardless, and plan to use it in all future projects. With just the built-in Rails validations support this already is an amazingly awesome tool to use!

Thanks!
Michael

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions