Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Validate a model using validation tools provided by ActiveRecord even though the model does not have a corresponding table

branch: master

This branch is 0 commits ahead and 0 commits behind master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 .gitignore
Octocat-spinner-32 History.txt
Octocat-spinner-32 Manifest.txt
Octocat-spinner-32 PostInstall.txt
Octocat-spinner-32 README.markdown
Octocat-spinner-32 active_record_no_table.gemspec
README.markdown

active_record_no_table

Introduction

Using ActiveRecord validation utilitites is difficult if you do not have a table for your model. This gem makes it easy to use validation tools even if the model does not have a corresponding table.

This gem works with Rails 2.1 and higher.

How to install

  
gem sources -a http://gems.github.com
sudo gem install neerajdotname-active_record_no_table
  
  
config.gem "neerajdotname-active_record_no_table", 
           :lib => active_record_no_table',
           :source => 'http://gems.github.com'                                        
  

How to use this gem

  
class Contact   Format::EMAIL,
                        :message => "^The email address is not valid. Please enter a valid email address.",
                        :if => Proc.new { |record| record.email.not_blank?}   
end

# in controller
@contact  = Contact.new(params[:contact])
if @contact.valid?
  ...
end

# using script_console
>> c = Contact.new
=> #
>> c.valid?
=> false
>> c.errors.full_messages
=> ["Please enter your name", "Please enter the message that you want to send", "Please enter your email address"]

Feedback

Email me: neerajdotname [at] gmail (dot) com

source code

http://github.com/neerajdotname/active_record_no_table/tree/master

Author Blog

http://www.neeraj.name

License

MIT

Copyright (c) 2009 neerajdotname

Something went wrong with that request. Please try again.