Thanks Sergio.
But I've already tried using "to_label" but it didn't make a
difference. And after reading our link I realized it shouldn't make
a difference because I'm already using ":name" in every table already.
I think I just need to find a way to turn a "has many" foreign key
into a link. something like:
def kids
collect.link(kids_m).join(",")
end
but, of course this doesn't work because I'm still a ruby novice.
Dave
On Dec 16, 1:14 am, "Sergio Cambra .:: entreCables - Symbol Servicios
Informáticos S.L. ::." <[email protected]> wrote:
> El Monday 15 December 2008 20:33:11 dschruth escribió:
>
>
>
> > I'm building a composite association link out of two foreign keys to
> > the same table.
>
> > And I've tried three approaches none of which are working.
> > ---------------------------------------------------------------------------
> >--------- class Parent < ActiveRecord::Base
>
> > has_many :kids_m, :foreign_key => :mom_id, :class_name => "Kid"
> > has_many :kids_f, :foreign_key => :dad_id, :class_name => "Kid"
>
> > # define the single composite association column
> > def kids
> > if (sex == "male")
> > kids_m
> > else
> > if sex == "female"
> > kids_f
> > end
> > end
> > end
>
> > end
> > ---------------------------------------------------------------------------
> >-------
>
> > But this results in :
> > #<Kid:0x2a99372f08>#<Kid:0x2a99371658>... etc
>
> > I tried turning these into links using:
> > ------------------------------------------------------
> > module ParentsHelper
> > def solid_secondary_analyses_column(record)
> > record.kids_m.first(3).collect{|kid_m| h(kid_m)}.join(', ') #BUT
> > NO LINK!!!
> > # can somebody tell me how to get "link_to" working with this?
> > end
> > end
> > ------------------------------------------------------
>
> > I've also tried just
> > ---------------------------------------------------------------------------
> >-- class Parent < ApplicationController
> > config.columns[:kids].set_link('nested', :parameters =>
> > {:associations => :kids_m})
> > end
> > -------------------------------------------------------------------
> > which works! but only for one association... which brings us back to
> > the original problem....
>
> > Any Ideas on how to do this?
>
> Define a to_label method in your
> model:http://github.com/activescaffold/active_scaffold/wikis/describing-rec...
>
> --
> Sergio Cambra .:: entreCables - Symbol Servicios Informáticos S.L. ::.
> Nicolás Guillén 6, locales 2 y 3. 50.018 Zaragoza
> T) 902 021 404 F) 976 52 98 07 E) [email protected]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"ActiveScaffold : Ruby on Rails plugin" 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/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---