Given this class definition:
User < ActiveRecord::Base
validates_uniqueness_of :user_name, :on => :create
validates_presence_of :password_hint, :on => :update
validates_format_of :email, :with =>
/^([EMAIL PROTECTED])@((?:[-a-z0-9]+\.)+[a-z]{2,})$/
end
First, ActiveRecord will search for a table called users in the
database. If it finds one, you now have a model that contains all
CRUD operations (User.new, User.find, User.destroy, etc.) along with
properties for all the fields in that table. You also have server
side validation of a unique user name only upon creation, a password
hint that's required only when the user object has been updated and an
email validation that runs whenever the object is persisted.
At it's simplest, you can have a class definition that looks like this:
User < ActiveRecord::Base
end
This will still give you all of your CRUD function along with other
functions such as find, find_all, etc.
Active record doesn't really have anything to do with form creation.
That's part of 'scaffolding' which in essence is code generation that
is meant to be overwritten once you start to flesh out the program.
On 9/22/05, Steve Bryant <[EMAIL PROTECTED]> wrote:
> I'm not sure that I completely follow the active record concept.
>
> I have some custom tags that I use for form generation that will
> optionally alter the database table to match the form (just be
> creation of tables/fields).
>
> http://www.bryantwebconsulting.com/cftags/cf_sebForm.htm
>
> I am also working on a code generator to generate said custom tags
> (among other things).
>
> Is that similar to the active record concept?
>
> Steve
>
> At 09:38 PM 9/22/2005, John Farrar wrote:
> >The Active Record concept and the Forms generation are the two biggest
> >concepts I would like to see added to development. As some others have said
> >here... the rapid prototyping is likely the biggest attraction to Ruby. The
> >ability to get a data model to be reflected in objects in an automated
> >fashion is also nice. Full CRUD in an instance.
>
>
>
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email to
> [email protected] with the words 'unsubscribe cfcdev' as the subject of the
> email.
>
> CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
> (www.cfxhosting.com).
>
> CFCDev is supported by New Atlanta, makers of BlueDragon
> http://www.newatlanta.com/products/bluedragon/index.cfm
>
> An archive of the CFCDev list is available at
> www.mail-archive.com/[email protected]
>
>
>
--
Marlon
"And I Sleep, and I dream of the person I might have been, and I'll be
free again
And I Speak, like someone who's been to the highest peaks, and back again
And I Swear, that my grass is greener than anyoness, until I believe again"
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).
CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]