Search code examples
ruby-on-railsrubyruby-on-rails-3google-mapsgmaps4rails

GMaps4Rails showing map, but no place to create location


Im using the gmaps4Rails gem and I followed the instructions and am getting a map but no "new location" button.

I've watched the youtube video like 4 times and it shows on there that you don't have to create a form or anything, its all created for you.
This is my server output

  Rendered /usr/lib/ruby/gems/1.8/gems/gmaps4rails-0.7.7/app/views/gmaps4rails/_gmaps4rails.html.erb (2.6ms)
  Rendered layouts/_stylesheets.html.erb (1.5ms)
  Rendered layouts/_header.html.erb (5.5ms)
  Rendered layouts/_footer.html.erb (0.7ms)

I've read through all the wiki's and I found ways to customize the markers, but I don't want that.
I just want to be able to add 1 marker to the map.
I also tried adding the .css and .js files to my app and then nothing showed up.

Does it not work on localhost ?
Or is it because I'm trying to create the location inside the creation of another object?

I've tried just this too:

      <%= f.text_field :address %>

But it throws a "You must provide an address" error before it creates it.


Solution

  • In the screencast, I use a scaffold generator which builds the form for me at the beginning of the video (the whole app is made from scratch)

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

    You need to create your migration and controller action + views yourself if you don't use it.

    I really suggest you have a look at http://railsforzombies.org to learn the basics of Rails.