Lets talk about your possibilities to use Icons for actionlinks.
I will use ‘fire’ action_link introduced in Actionlink response and ignore to demonstrate the options.

First option: “prefix” you label with an icon using css

That s quite easy, you just have to take a look at css file of activescaffold to find the pattern (new and search actions are already using this option).

.active-scaffold tr.record td.actions a.fire {
background: url("../../../images/fire.png") 0 0 no-repeat;
padding-left: 19px;
background-position: 1px 50%;
background-repeat: no-repeat;
}

Second option: replace your label with an icon using css

There are several techniques available and all of them have their pro s and con s.
I will just show you one of them, which requires to set action_links label to an empty string.

PlayersController:

  conf.action_links.add 'fire', :label => '', :confirm => 'are_you_sure', :type => :member, :method => :put, :position => false

css

.active-scaffold td.actions a.fire {
display:block;
width: 18px;
height: 18px;
background: url("../../../images/fire.png") 0 0 no-repeat;
background-position: center center;
} 

Third option: Using an image tag

Remove any css code you ve added for the first two options and change your action_link configuration in players controller

  conf.action_links.add 'fire', :image => {:name => 'fire.png', :size => '16x16'}, :confirm => 'are_you_sure', :type => :member, :method => :put, :position => false

If you want to use this option to change active_scaffolds native actionlinks such as edit, you can do that as well.
Add the following to your application_controller.rb:

..
ActiveScaffold::Config::Update.link = ActiveScaffold::DataStructures::ActionLink.new('edit', :image => {:name => 'update.png', :size => '16x16'}, :type => :member, :security_method => :update_authorized?)
class ApplicationController < ActionController::Base
..
Advertisements