Closed arbak closed 10 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.
no news = good news?
@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.
@rajesh2210 what about reading the doc, first page if github project's page?
@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>
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… (?)
... 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.
@Benjamin Roth, Thank you,
Its working fine, you are RockStar Superbh.......
Thanks alot
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.
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.
@Benjamin Roth,
Any Solution please share with me.
Thanks.
It all work no error is shown but the map doesnt shown for me solid box only come for me
@subhashreev those are css issues, not related to the gem itself
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..
@pvin the generator is not necessary anymore in v2.x check the readme
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?