Class: ActiveadminAddons::Generators::AssetsGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/activeadmin_addons/assets/assets_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_javascriptsObject



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/generators/activeadmin_addons/assets/assets_generator.rb', line 6

def add_javascripts
  file_path = 'app/assets/javascripts/active_admin'
  reference = "#= require active_admin/base\n"

  begin
    inject_into_file("#{file_path}.js.coffee", coffee_assets, after: reference)
  rescue
    reference = "//= require active_admin/base\n"
    inject_into_file("#{file_path}.js", js_assets, after: reference)
  end
end

#add_stylesheetsObject



18
19
20
21
22
23
24
25
26
# File 'lib/generators/activeadmin_addons/assets/assets_generator.rb', line 18

def add_stylesheets
  file_path = 'app/assets/stylesheets/active_admin'

  begin
    prepend_file("#{file_path}.scss", css_assets)
  rescue
    prepend_file("#{file_path}.css.scss", css_assets)
  end
end