apneadiving / Google-Maps-for-Rails

Enables easy Google map + overlays creation in Ruby apps
https://apneadiving.github.io/
MIT License
2.26k stars 382 forks source link

Could not find generator gmaps4rails:install #268

Closed arbak closed 10 years ago

arbak commented 12 years ago

gmaps4rails doesn't work in new version:

Could not find generator gmaps4rails:install

My version:

C:\dev>ruby -v ruby 1.9.3p194 (2012-04-20) [i386-mingw32]

rails 3.2.8

gmaps4rails 1.5.5

Where is problem?

apneadiving commented 12 years ago

What did you type exactly?

Sent from my iPhone

On 22 sept. 2012, at 00:21, Lukas Arbaczewski notifications@github.com wrote:

gmaps4rails doesn't work in new version:

Could not find generator gmaps4rails:install

My version:

C:\dev>ruby -v ruby 1.9.3p194 (2012-04-20) [i386-mingw32]

rails 3.2.8

gmaps4rails 1.5.5

Where is problem?

— Reply to this email directly or view it on GitHub.

apneadiving commented 12 years ago

no news = good news?

rajesh2210 commented 10 years ago

@Benjamin Roth I am using ruby 2.0.0, and rails 4.0.0 with gem 'gmaps4rails' gem is installing but when i am doing 'rails generate gmaps4rails:install' its showing 'Could not find generator gmaps4rails:install'.

Any solution you have please share.

apneadiving commented 10 years ago

@rajesh2210 what about reading the doc, first page if github project's page?

rajesh2210 commented 10 years ago

@Benjamin Roth, I am following this document....

Google maps for Rails – step by step

Based on “gmaps4rails” gem, we will implement google maps in simple Rails 3 application.

1.) We will start with creating new project. Go to the directory of your choice and in your terminal type:

rails new projectname

cd projectname

2.) Edit gemfile by adding new line:

gem 'gmaps4rails'

and bundle it by typing in your terminal:

bundle install

3.) Add gmaps4rails assets to the application:

rails generate gmaps4rails:install

4.)Generating simple scaffold will serve enough for our purposes:

rails g scaffold Location name:string address:string longitude:float latitude:float gmaps:boolean

5.) In /app/models/location.rb inculde acts_as_gmappable line and gmaps4rails_address method:

class Location < ActiveRecord::Base  attr_accessible :address, :latitude, :longitude, :name  acts_as_gmappable     def gmaps4rails_address       address   end end

6.) We can migrate now, so our database reflect data model:

rake db:migrate

7.) Add <%= yield :scripts %> in /app/views/layouts/application.html.erb

<!DOCTYPE html>

  Carpooling   <%= stylesheet_link_tag    "application", :media => "all" %>   <%= javascript_include_tag "application" %>   <%= csrf_meta_tags %> <%= yield %> <%= yield :scripts %>

8) In /app/controllers/locations_controller.rb add @json = Location.all.to_gmaps4rails

class LocationsController < ApplicationController   def index     @locations = Location.all     @json = Location.all.to_gmaps4rails     respond_to do |format|       format.html # index.html.erb       format.json { render json: @locations }     end   end . . . end

9.) To display map with locations we need to modify index view located in app/views/locations/index.html.erb by adding following line:

<%= gmaps4rails(@json) %>

Now we should be able to see results of our work. Just simply run rails server:

rails server

and in a browser of your choice go to:

http://localhost:3000/locations

Now you should see google map and link for adding new locations to your map. If something went wrong, well it must be reason for this ;) For me configuration with Ruby 2.0, Rails 3.2.12 and gmaps4rails 1.5.6 works well. tbc… (?)

apneadiving commented 10 years ago

... Then use v. 1.5.6

Sent from my iPad

On 24 Oct 2013, at 08:49, rajesh2210 notifications@github.com wrote:

@Benjamin Roth, I am following this document....

Google maps for Rails – step by step

Based on “gmaps4rails” gem, we will implement google maps in simple Rails 3 application.

1.) We will start with creating new project. Go to the directory of your choice and in your terminal type:

rails new projectname

cd projectname

2.) Edit gemfile by adding new line:

gem 'gmaps4rails'

and bundle it by typing in your terminal:

bundle install

3.) Add gmaps4rails assets to the application:

rails generate gmaps4rails:install

4.)Generating simple scaffold will serve enough for our purposes:

rails g scaffold Location name:string address:string longitude:float latitude:float gmaps:boolean

5.) In /app/models/location.rb inculde acts_as_gmappable line and gmaps4rails_address method:

class Location < ActiveRecord::Base attr_accessible :address, :latitude, :longitude, :name acts_as_gmappable

def gmaps4rails_address address end end

6.) We can migrate now, so our database reflect data model:

rake db:migrate

7.) Add <%= yield :scripts %> in /app/views/layouts/application.html.erb

<!DOCTYPE html>

Carpooling <%= stylesheet_link_tag "application", :media => "all" %> <%= javascript_include_tag "application" %> <%= csrf_meta_tags %>

<%= yield %> <%= yield :scripts %>

8) In /app/controllers/locations_controller.rb add @json = Location.all.to_gmaps4rails

class LocationsController < ApplicationController def index @locations = Location.all @json = Location.all.to_gmaps4rails respond_to do |format| format.html # index.html.erb format.json { render json: @locations } end end . . . end

9.) To display map with locations we need to modify index view located in app/views/locations/index.html.erb by adding following line:

<%= gmaps4rails(@json) %>

Now we should be able to see results of our work. Just simply run rails server:

rails server

and in a browser of your choice go to:

http://localhost:3000/locations

Now you should see google map and link for adding new locations to your map. If something went wrong, well it must be reason for this ;) For me configuration with Ruby 2.0, Rails 3.2.12 and gmaps4rails 1.5.6 works well. tbc… (?)

— Reply to this email directly or view it on GitHub.

rajesh2210 commented 10 years ago

@Benjamin Roth, Thank you,

Its working fine, you are RockStar Superbh.......

Thanks alot

rajesh2210 commented 10 years ago

Hello, Benjamin Roth

gmaps4rails gem is working fine in development environment, but when i am starting the server in production environment its not working, means latitude and longitude are not saving in database,

Any solution you have please share.

rajesh2210 commented 10 years ago

Hello, Benjamin Roth

gmaps4rails gem is working fine in development environment, but when i am starting the server in production environment its not working, means latitude and longitude are not saving in database,

Any solution you have please share.

rajesh2210 commented 10 years ago

@Benjamin Roth,

Any Solution please share with me.

Thanks.

subhashreev commented 10 years ago

It all work no error is shown but the map doesnt shown for me solid box only come for me

apneadiving commented 10 years ago

@subhashreev those are css issues, not related to the gem itself

pvin commented 10 years ago

Try this......... initially i used these gems and got error of Could not find generator gmaps4rails:install

ruby 2.0.0 rails 3.2.13 gmaps4rails-2.1.1

thn replaced gmaps4rails with older version

gmaps4rails -1.5.6

Working fine now..

apneadiving commented 10 years ago

@pvin the generator is not necessary anymore in v2.x check the readme