Sha256: 9524e49f4139df374ce49937dfe8c977c888d4ed5f52ef805f347855866c5549
Contents?: true
Size: 1008 Bytes
Versions: 5
Compression:
Stored size: 1008 Bytes
Contents
module Model class GmapsGenerator < Rails::Generators::NamedBase source_root File.expand_path('../templates', __FILE__) argument :field, type: :string, default: [], banner: "model" def copy_initializer_file @app_name = file_name inject_into_file "app/assets/javascripts/application.js", after: "//= require jquery_ujs" do <<-JS //= require gmaps4rails/gmaps4rails.base //= require gmaps4rails/gmaps4rails.googlemaps JS end inject_into_file "app/models/#{file_name}.rb", after: "ActiveRecord::Base" do <<-RUBY geocoded_by :address after_validation :geocode def address "\#{logradouro}, \#{numero}, \#{bairro}, \#{cidade.try(:cidade_estado)}" end RUBY end gem 'geocoder' gem 'gmaps4rails', "1.5.6" Bundler.with_clean_env do run "bundle install" run "rails generate migration add_latitude_and_longitude_to_#{@app_name.pluralize} latitude:float longitude:float" run "rake db:migrate" end end end end
Version data entries
5 entries across 5 versions & 1 rubygems