Re: undefined method & has_one

Steve Longdo
Wed, 01 Nov 2006 21:39:13 -0000

I think you want:

@category.employees.each { |emp| emp.bio }

On 11/1/06, Ryan
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:
>
>
> i''ve got 3 tables:
>
> here are the models
>
> class Category < ActiveRecord::Base     #category.rb
>         has_many        :employees
> end
>
>
> class Employee < ActiveRecord::Base     #employee.rb
>         belongs_to      :category
>         has_one         :bio
> end
>
>
> class Bio < ActiveRecord::Base          #bio.rb
>         belongs_to      :employee
> end
>
>
> i''m trying to get a recordset of all the bios in a view using:
>
> @category.employees.bio each do |bio|
>
> ... but i am getting "undefined method `bio'' for
Employee:Class"
>
>
>
> @category.employees does return a valid recordset
>
>
>
> Any ideas?
>
>
> Thanks!
>
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>


--
Thanks,
-Steve