Class: RailsGoogleMap::Generators::ViewsGenerator

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

Overview

Copies the map partial into the host app so its markup can be edited:

rails generate rails_google_map:views
rails generate rails_google_map:views --format slim

App view paths take precedence over the engine's, so the copy is picked up with no further configuration.

Constant Summary collapse

FORMATS =
%w[erb slim].freeze

Instance Method Summary collapse

Instance Method Details

#copy_map_partialObject



25
26
27
28
29
30
31
32
# File 'lib/generators/rails_google_map/views/views_generator.rb', line 25

def copy_map_partial
  format = options[:format].to_s.downcase
  unless FORMATS.include?(format)
    raise Thor::Error, "Unknown format #{options[:format].inspect}. Use #{FORMATS.join(' or ')}."
  end

  copy_file "_map.html.#{format}", "app/views/rails_google_map/_map.html.#{format}"
end