Ok I solved it using an action like url instead of a nested url and
that works!

On 1 juil, 18:14, Sylvain <[email protected]> wrote:
> I'm trying to have a solution via the use of helpers.
> In DeviceHelper,
> I've created a function links_column. The goal is to give link for the
> right Links Table, in nested mode. For that, I first recreate the
> good
> view and add a link. The link is wworking correctly in a non nested
> mode.
> In a nested mode, I've got an error:
> ActiveScaffold::MalformedConstraint in LinksController#show_list
> Malformed constraint `Link#aspen_topo_file_id'. If it's a legitimate
> column, and you are using a nested scaffold, please specify or double-
> check the reverse association name.
> This is coming from vendor/plugins/active_scaffold/lib/active_scaffold/
> actions/nested.rb:33:in `include_habtm_actions'
>
> I have a Model named AspenTopoFile but the relationship between this
> Model and the Link model is a has_many/belongs_to one. So I don't
> understand why this error is raised...
>
> Do you know why?
>
> Here is my helper method:
>
> def links_column(record)
>  if record.src_links.count + record.dst_links.count > 3
>       if record.src_links.count >= 3
>         "<a href=/links/show_list/#{record.id}?_method=get&eid=#{params
> [:eid]}&nested=true&parent_model=Device>" + record.src_links.first
> (3).collect{|ac| h(ac.name)}.join(', ')  +  " ... ("  +
> (record.src_links.count + record.dst_links.count).to_s + ")" + "</a>"
>       else
>         i = record.src_links.count
>         "<a href=/links/show_list/#{record.id}?_method=get&eid=#{params
> [:eid]}&nested=true&parent_model=Device>" + record.src_links.first
> (3).collect{|ac| h(ac.name)}.join(', ') + record.dst_links.first(3-
> i).collect{|ac| h(ac.name)}.join(', ') +  " ... ("  +
> (record.src_links.count + record.dst_links.count).to_s + ")"
>       end
>     else
>       if record.src_links.count >= 3
>         "<a href=/links/show_list/#{record.id}?_method=get&eid=#{params
> [:eid]}&nested=true&parent_model=Device>" + record.rc_links.first
> (3).collect{|ac| h(ac.name)}.join(', ')
>       else
>         i = record.src_links.count
>         "<a href=/links/show_list/#{record.id}?_method=get&eid=#{params
> [:eid]}&nested=true&parent_model=Device>" + record.src_links.first
> (3).collect{|ac| h(ac.name)}.join(', ') + record.dst_links.first(3-
> i).collect{|ac| h(ac.name)}.join(', ')
>       end
>     end
> end
>
> On 1 juil, 15:44, Sylvain <[email protected]> wrote:
>
> > On 1 juil, 12:57, "Sergio Cambra .:: entreCables S.L. ::."
>
> > <[email protected]> wrote:
> > > On Miércoles, 1 de Julio de 2009 11:53:28 Sylvain escribió:
>
> > > > Hi again,
> > > > I have two Models has follow:
>
> > > > Class Device
> > > > has_many :links, :foreign_key => "src_device_id"
> > > > has_many :links, :foreign_key => "dst_device_id"
>
> > > This is wrong, you can't have two associations with the same name, rails 
> > > will
> > > ignore the first association. If you try in the console (script/console)
> > > Device.first.links you can see SQL generated by rails will be use
> > > dst_device_id.
>
> > One question about that,
> > I've done taht in order to be OK with rails:
>
> > Class Device
> > has_many :src_links, :class_name => "Link", :foreign_key =>
> > "src_device_id"
> > has_many :dst_links, :class_name => "Link", :foreign_key =>
> > "dst_device_id"
>
> > Now I would like to have column 'Link' which would behave like a
> > normal "has_many" columns (i.e. ability to click and to see the links)
>
> > So first I did that:
>
> > def links
> >    src_links + dst_links
> > end
>
> > But that doesn't do what I want...
> > Is there any other way to do that?
>
> > Thanks in advance,
--~--~---------~--~----~------------~-------~--~----~
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