On Tuesday, April 11, 2006, at 12:53 PM, Alana wrote:>Hi,
>
>My tables are as follows:
>"tblusers" - primary key "TblUsersID"
>"tblregisteredphones" - primary key
"TblRegisteredPhonesID"
> - foreign key "intUserID"
>
>My models are as follows:
>
>class Registeredphone < ActiveRecord::Base
> set_table_name "tblregisteredphones"
> belongs_to :user,
> :foreign_key => "intUserID"
> set_primary_key(:TblRegisteredPhonesID)
>end
>
>class User < ActiveRecord::Base
> set_table_name "tblusers"
> has_many :registeredphones,
> :foreign_key => "TblUsersID"
> set_primary_key(:TblUsersID)
>end
>
>Is this correct?
>
>Thanks,
>Alana
>
>--
>Posted via http://www.ruby-forum.com/.
>_______________________________________________
>Rails mailing list
>Rails@lists.rubyonrails.org
>http://lists.rubyonrails.org/mailman/listinfo/rails
Looks correct. If you are never going to use the relation from
registeredphones to users you do not need the "has_many" on the
registeredphones model.
--
Posted with http://DevLists.com. Sign up and save your mailbox.