daily pastebin goal
32%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. How to put google map on the page
  2. class UsersController < ApplicationController
  3. def show
  4.         if !current_user then
  5.  
  6.         redirect_to({:controller => "users", :action => "new"}, :notice => 'You need register before reading the profile')
  7.         return
  8.  
  9.     end
  10.     @user = User.find(params[:id])
  11.     @json = @user.to_gmaps4rails
  12.     respond_to do |format|
  13.       format.html # show.html.erb
  14.       format.xml  { render :xml => @user }
  15.     end
  16. >  end
  17.    
  18. class User < ActiveRecord::Base
  19.     acts_as_authentic  
  20.     acts_as_gmappable
  21.  validates_presence_of :country, :city, :street, :message => 'must be filled'  
  22.    has_many :propose
  23.  
  24.     def gmaps4rails_address
  25.     address
  26.     #describe how to retrieve the address from your model, if you use directly a db column, you can dry your code, see wiki
  27.       #"#{self.street}, #{self.city}, #{self.country}"
  28.     end
  29. end
  30.    
  31. <%= @user.name %>
  32. <%= @user.email %>
  33.  
  34. <%= gmaps4rails(@json) %>
  35. <%= yield :scripts %>
  36. <%= render 'layouts/comment' %>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top