Class: BootswatchRails::Generators::CleditorGenerator

Inherits:
ActiveRecord::Generators::Base
  • Object
show all
Defined in:
lib/generators/bootswatch_rails/cleditor/cleditor_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_to_assetsObject



13
14
15
16
17
18
# File 'lib/generators/bootswatch_rails/cleditor/cleditor_generator.rb', line 13

def add_to_assets
  file = "app/assets/javascripts/application.js"
  inject_into_file file, "\n//= require jquery.cleditor", after: /require jquery_ujs$/
  file = "app/assets/stylesheets/application.css"
  inject_into_file file, " *= require jquery.cleditor\n", before: /^.*require_self/
end

#add_to_viewObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/generators/bootswatch_rails/cleditor/cleditor_generator.rb', line 20

def add_to_view
  file = "app/views/#{table_name}/index.html.erb"
  columns.each do |column|
    gsub_file file, / (#{name}\.#{column}) /, " raw(\\1) "
  end
  file = "app/views/#{table_name}/show.html.erb"
  columns.each do |column|
    gsub_file file, / (@#{name}\.#{column}) /, " raw(\\1) "
  end
  file = "app/views/#{table_name}/_form.html.erb"
  columns.each do |column|
    gsub_file file, / (:#{column}) /, " \\1, input_html: { class: 'cleditor' } "
  end
end