On Jul 7, 9:48 pm, Cliff Pruitt
<lists.cpru...-0X7n6C/JC56123jP4xv/FQ@public.gmane.org>
wrote:> Hey everyone, I''m just beginning rails (and this list) and I am
> having a little trouble with something. I''m trying to make sure I
> validate everything that needs to be validated, but I''m having a
hard
> time grasping how ActiveRecord handles validations. I have a schema
> like this:
>
> Account
> - has_many Users
> - has_one ServicePlan
>
> I''ve included my code sample at the bottom of the email.
Basically I
> can do a ''validates_presence_of :service_plan'' but I
can''t figure out
> how to ''validates_numericality_of :service_plan'' or
> ''validates_numericality_of :service_plan_id'' or anything.
I BELIEVE
> I understand that I should never have to access
> Account.service_plan_id directly since I would always use
> Account.service_plan.id, so is it correct that I dont have to
> validate the type of the service plan Id? I just "trust" rails?
The ID column is always an auto-incementing integer, so you don''t have
to validate it.
> Also, as a side question, how does rails translate class names into
> property names? I don''t quite grasp the naming convention. Is
the
> above correct in that the ServicePlan belonging to an Account object
> is ''MyAccount.service_plan'' and not
''MyAccount.servicePlan''?
Right. Ruby convention is all lower case, with underscores between
English words to make it more readable (as opposed to, say, Java,
which capitalizes the first letter of words after the first word).
> Sorry for the beginner questions. I guess I gotta start somewhere
> right?
Don''t apologize, that''s what this list is for!
Jeff
www.softiesonrails.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---