From: T- Di Date: 2012-08-07T01:09:35+09:00 Subject: Re: Join with ActiveRecord using non-standard schema Hassan Schroeder wrote in post #1071445: > On Mon, Aug 6, 2012 at 8:38 AM, T- Di wrote: > >> The table AgreementType contains the field 'name' that I want to use. >> >> Quick recap from the first message: >> - There are 2 tables for which I created individual classes: >> a. Agreement >> b. AgreementType >> - The field 'AGREEMENT_TYPE_ID' is present in both tables, so I can use >> it to join their contents. >> - The field 'name' is on the AGREEMENT_TYPE_ID > > OK, so it's not a method of Agreement. Then you're looking for e.g. > @agreements.first.agreement_type.name > > Maybe worth reviewing the Rails guide on AR relationships... That's what I was trying to explain from the begining... :) @agreements.first.agreement_type.name returns: NoMethodError: undefined method `agreement_type' for # @agreements.first.AgreementType.name returns: NoMethodError: undefined method `name' for nil:NilClass -- Posted via http://www.ruby-forum.com/.