Thanks for the reply Chris.. I'll switch away from Camelcase.. I use that at work all day long (C++) so I'm used to looking at it.
I initially used the generator but when revising tables it didn't want to run anymore complaining some of the files were already there -- which is why I resorted to hand-edits. I'll do some more reading on what you suggested.. Thx! -- Rick On Jul 28, 2011, at 11:22 PM, Chris Kottom wrote: > Are you not using generators for the initial creation of your model and > migration source files? I'm asking because I think I can count on one hand > the number of times I've ever written out a create_table function myself. > Your inputs from the command line should do all this for you along with some > of the work of setting up your model associations (e.g. the belongs_to call > in your Address class definition) and save you some effort. If you're using > the generators properly, you may never have to touch the migration files for > simpler applications. > > rails g scaffold user acctLocked:boolean familyId:integer > isProfileSetup:boolean ... > rails g model address user:references address:string city:string ... > > For more info: > http://guides.rubyonrails.org/getting_started.html > http://guides.rubyonrails.org/command_line.html#rails-generate > > One other small thing: you're writing your variable names using camel case > (lowerCaseWithCapitalsIndicatingWordBoundaries) whereas the more widely > recognized Ruby convention is to use all_lower_case_with_underscores. I left > your variable names as-is in the sample code above, but if it's code that > anyone else will ever see or work on, you might consider changing it. > > On Fri, Jul 29, 2011 at 4:43 AM, Rick & Nellie Flower <[email protected]> > wrote: > Ok.. Still working on this stuff.. I've got the t.reference in the migration > for the address class and moved the belongs_to and has_one in the model > classes as indicated (I didn't notice that!). > > I noticed in the association-basics that I should be putting a create_table > function (if that's what > it's called) in the CreateUsers class for Migrations but I'm concerned about > doing that since I'll be using the address class on more than just the > 'users' class -- does it really belong there or ?? > Perhaps I'm overthinking this.. ?? > > Below are the two class definitions for both the model & migration : > > class Address < ActiveRecord::Base > belongs_to :user > belongs_to :organization > belongs_to :supplier > end > > class CreateAddresses < ActiveRecord::Migration > > def self.up > create_table :addresses do |t| > t.string :address > t.string :city > t.string :state > t.string :zip > t.string :email > t.string :phone > t.references : users > > t.timestamps > end > end > > def self.down > drop_table :addresses > end > end > > ================================= > class User < ActiveRecord::Base > enum_attr :accountType, %w(regular admin site_admin), :init=>:regular > > has_one :name > has_one :address > has_one :organization > > end > > class CreateUsers < ActiveRecord::Migration > > def self.up > create_table :users do |t| > t.boolean :acctLocked > t.integer :familyId > t.boolean :isProfileSetup > t.datetime :lastLogin > t.string :password > t.string :securityQ > t.string :securityA > t.string :username > t.enum :accountType > > t.timestamps > end > > create_table :a > end > > def self.down > drop_table :users > end > end > > -- > 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > > > -- > 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

