-
Notifications
You must be signed in to change notification settings - Fork 330
Dynamic action links groups
scambra edited this page Oct 29, 2012
·
5 revisions
It's possible to add an action which display dynamically a group of actions, adding a controller action which builds the action links group and displays it with ActiveScaffold.display_dynamic_action_group
class TeamsController < ApplicationController
active_scaffold :team do |conf|
....
conf.action_links.member.add 'report', :position => false
....
end
def report
@record = find_if_allowed(params[:id], :read)
end
end
# report.js.erb
<%
html = content_tag :ul do
@record.report_types.each do |report_type|
content_tag :li, link_to(report_type.to_label, report_path(@record, report_type))
end.join(''.html_safe)
end
%>
ActiveScaffold.display_action_link_group('<%= get_action_link_id active_scaffold_config.action_links[:report], @record %>', '<%= escape_javascript html %>');