This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
.gitignore | ||
| |
History.txt | ||
| |
Manifest.txt | ||
| |
PostInstall.txt | ||
| |
README.markdown | ||
| |
active_record_no_table.gemspec | ||
| |
lib/ |
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 < ActiveRecord::NoTable
attr_accessor :name, :email, :body, :subject
validates_presence_of :name, :email, :body
validates_format_of :email,
:with => 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
License
MIT
Copyright (c) 2009 neerajdotname








