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