Class: EmailManager::Generators::ViewsGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/email_manager/views_generator.rb

Instance Method Summary collapse

Instance Method Details

#copy_controllerObject

Addes the controller to the parent project



39
40
41
# File 'lib/generators/email_manager/views_generator.rb', line 39

def copy_controller
  template "controllers/email_manager/managed_emails_controller.rb", "app/controllers/email_manager/managed_emails_controller.rb"
end

#copy_viewsObject

Adds the views to the parent project



27
28
29
30
31
32
33
34
35
36
# File 'lib/generators/email_manager/views_generator.rb', line 27

def copy_views
  #theoretical support in the future for haml
  extension = "." + template_engine
  file_names = %w{index show _pagination _search_form }
  file_names.each do |file_name|
    source = "views/email_manager/managed_emails/" + file_name + ".html" + extension
    destination = "app/views/email_manager/managed_emails/" + file_name + ".html" + extension
    copy_file source, destination
  end
end

#template_engineObject

Stolen from Kaminari gem



17
18
19
20
21
22
23
24
# File 'lib/generators/email_manager/views_generator.rb', line 17

def template_engine
  te = options[:template_engine].try(:to_s).try(:downcase) || 'erb'
  if te == "haml"
    return "haml"
  else
    return "erb"
  end
end