-
Notifications
You must be signed in to change notification settings - Fork 330
Action Links Order
The order of action links is defined by order in action_links array. The follow line in list_actions
and list_header
partials iterates over action_links adding them to the page:
active_scaffold_config.action_links.each
Due to CSS, they are displayed in reverse order at list header and in right order for each record.
Custom action links (action links created in your controller with config.action_links.add
or config.nested.add_link
) are added to action_links array first, and default action links (links from actions like :create, :search, :update and so on) are added last. The order of action links is:
- At list header, default action links in reverse order and then custom action links in reverse order
- At each record, custom action links and then default action links.
So you can change action link order overriding config.actions in the controller, although you cannot mix custom action links with default ones. To change the default order for all controllers use set_defaults in ApplicationController:
ActiveScaffold.set_defaults do |config|
config.actions = [:create, :list, :search, :show, :update, :delete, :nested, :subform]
end
To mix custom action links, to get something like custom edit show delete another_custom
, you can use per-request configuration to remove and add some links from action_links array:
before_filter :action_links_order
protected
# Moving action_name link to last
def action_links_order
links = active_scaffold_config.action_links
link = links[:action_name]
if link
links.delete :action_name
links << link
end
end