Giter Site home page Giter Site logo

ror_gmaps's Introduction

RoR_gmaps

Requirements: Ruby 1.8.7 Ruby on Rails 3.2.13 Install gmaps4rails: Refernece: https://github.com/apneadiving/Google-Maps-for-Rails Creating a Demo App of Google Maps with Ruby on Rails

Steps Takens to Create This app

  1. Use the following code to generate new ruby on rails app

     rails new gmap
    
  2. edit gmap/Gemfile

     add gem 'gmaps4rails'
    
  3. copy things gmaps4rails into asset

    cd into gmap $rails generate gmaps4rails:install

  4. modify app/views/layouts/application.html.erb to add required library

    between body and html tag add

    <%= yield :scripts %>
  5. Include css tag in application.html.erb in header

     <%= stylesheet_link_tag 'gmaps4rails' %> 
    
  6. Create a character model

     rails g scaffold character name:string address:string activity:string longitude:float latitude:float gmaps:boolean 
    
  7. Modify the user model to add the following (app/models/user.rb)

     acts_as_gmappable
     def gmaps4rails_address
     #describe how to retrieve the address from your model, if you use directly a db column, you can dry your code, see wiki
     address
     end
    
  8. Add the following line to migration (db/migrate/_____create_character.rb)

     add_column :character, :latitude,  :float #you can change the name, see wiki
     add_column :character, :longitude, :float #you can change the name, see wiki
     add_column :character, :gmaps, :boolean #not mandatory, see wiki
    
  9. Include gmaps object into the controller (app/controllers/users_controller.rb)

     @json = User.all.to_gmaps4rails
    
  10. Include the gmaps into the view (app/views/users/index.html.erb)

    <%= gmaps4rails(@json) %>
    
  11. Remove the following file

    public/index.html
    
  12. modify routers.rb add

    root :to => 'characters#index'
    
  13. update db

    rake db:migrate
    

ror_gmaps's People

Contributors

wmaiouiru avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.