Project

veracious

0.0
No commit activity in last 3 years
No release in over 3 years
It sure would be awesome if ActiveResource actually allowed us to do client-side validation of our ActiveResource objects like their documentation promises: http://apidock.com/rails/ActiveResource/Base
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 2.3.3
 Project Readme

Introduction¶ ↑

Gee… it sure would be awesome if ActiveResource actually allowed us to do client-side validation of our ActiveResource objects like the ActiveResource::Base documentation promises

Installation¶ ↑

To install, add this to your environment.rb:

config.gem 'veracious', :version => '0.0.2', :lib => 'veracious', :source => 'http://gemcutter.org'

Next, go to the root of your project in a shell and run this command (you may need to use “sudo” depending on your environment):

sh# rake gems:install

Usage¶ ↑

You can now create a protected “validate” method in your ActiveResource::Base-derived class:

class Book < ActiveResource::Base
  self.site = 'http://myservice.domain'

  protected
  def validate
    errors.add(:author, 'is required') if (author.blank? rescue true)
  end
end

Now, in your code, you can do the following:

console> b = Book.new
console> b.valid?
  ==> false
console> b.author = ''
console> b.valid?
  ==> false
console> b.author = 'Iain M. Banks'
console> b.valid?
  ==> true

When you call the valid? method on your active resource object, it will do client side validation. It will not send a request to the service provider for validation.