Module: ActiveAdmin::Sass::Helpers

Includes:
Sass::Rails::Helpers
Defined in:
lib/active_admin/sass/helpers.rb

Instance Method Summary collapse

Instance Method Details

#active_admin_image_path(asset) ⇒ Sass::Script::String

Provides a helper in SASS to ensure that the paths to image assets are always correct across Rails versions.

Example:

background: url(active_admin_image_path('some_image.png')) 0 0 repeat-x;

Will result in:

background: url("/images/active_admin/some_image.png") 0 0 repeat-x;

Or in Rails 3.1 with asset pipeline enebaled:

background: url("/assets/active_admin/some_image.png") 0 0 repeat-x;

Parameters:

  • asset (Sass::Script::String)

    the path to the image after */active_admin/

Returns:

  • (Sass::Script::String)

    path to the image



32
33
34
35
36
37
38
# File 'lib/active_admin/sass/helpers.rb', line 32

def active_admin_image_path(asset)
  if ActiveAdmin.use_asset_pipeline?
    asset_path(::Sass::Script::String.new("active_admin/#{asset.value}"), ::Sass::Script::String.new('image'))
  else
    ::Sass::Script::String.new("/images/active_admin/#{asset.value}", true)
  end
end