Here is my solution:

        def client_name_column(record)
                if record.respond_to?('deployment_id') && 
!record.deployment_id.nil?
                        deployment = Deployment.find(record.deployment_id)
                        if deployment.respond_to?('client_id') && !
deployment.client_id.nil?
                                client = Client.find(deployment.client_id)
                                link_to(h(client.name), {:action => :show, 
:parent_controller =>
'inactive_applications', :controller => 'clients', :id => client.id},
{ :class => "action", :position => "replace"})
                        end
                end
        end

The only problem that remains is that I have to hard code the
"parent_controller" value in the helper. At the moment I only need to
call it from one controller, but if I want to use the same helper from
another controller, I'm in trouble.

Anyone know enough about ruby reflection to tell me if there is any
way to get at the name of the controller calling this method?



On May 14, 2:49 pm, Kenny Ortmann <[email protected]> wrote:
> The problem with this is that from a users point of view it may not seem
> silly to have a link to the parent and grandparent.
>
> So from an active scaffold point of view, when you click on the parent link
> you get a scaffold view for the child-parent relationship.  If you click on
> grandparent you would get a scaffold view for the child-grandparent
> relationship which doesn't "really" exist.
>
> On Thu, May 14, 2009 at 1:46 PM, fattymelt <[email protected]> wrote:
>
> > On May 14, 6:25 am, "Sergio Cambra .:: entreCables S.L. ::."
> > <[email protected]> wrote:
> > > On Miércoles, 13 de Mayo de 2009 17:33:48 fattymelt escribió:
>
> > > > On May 12, 4:09 am, "Sergio Cambra .:: entreCables S.L. ::."
>
> > > > <[email protected]> wrote:
> > > > > El Friday 08 May 2009 23:58:23 fattymelt escribió:> I see no one ever
> > > > > responded to this ->
>
> > > > > >http://groups.google.com/group/activescaffold/msg/6745982271cda82a
>
> > > > > > But I have the exact same issue. As the OP says, it must be a
> > common
> > > > > > problem, so I think I am missing some obvious solution. Thanks.
>
> > > > > Use a field override and call to_label.
>
> > > > So, I did this, but all I get is the String. I, and the OP, were
> > > > hoping to get a link, just like you get with "single layer"
> > > > associations.
>
> > > > Just to be clear, if I have:
>
> > > > class ApplicationInstance < ActiveRecord::Base
> > > >    belongs_to :deployment
> > > > end
>
> > > > class Deployment < ActiveRecord::Base
> > > >    belongs_to :client
> > > > end
>
> > > > class Client < ActiveRecord::Base
> > > > end
>
> > > > When I am using "active_scaffold :application_instance" I can easily
> > > > include the :deployment column to display and link to
> > > > ApplicationInstance.Deployment, but I want to be able to add a :client
> > > > column that displays and links to
> > > > ApplicationInstance.Deployment.Client.  Your solution did allow me to
> > > > display ApplicationInstance.Deployment.Client, but I would like to
> > > > have it be a link.
>
> > > You can return a link in the field override instead of a string. There is
> > no
> > > automatic linking feature in ActiveScaffold for associations of
> > associations
>
> > Yes, this is what I have decided to do. I was hoping for a "inline"
> > link, but I'm not sure I can make that happen. The only example of a
> > link provided in the Field Overrides documentation is a popup link,
> > via link_to.
>
> > thanks.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to