Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How to put google map on the page
- class UsersController < ApplicationController
- def show
- if !current_user then
- redirect_to({:controller => "users", :action => "new"}, :notice => 'You need register before reading the profile')
- return
- end
- @user = User.find(params[:id])
- @json = @user.to_gmaps4rails
- respond_to do |format|
- format.html # show.html.erb
- format.xml { render :xml => @user }
- end
- > end
- class User < ActiveRecord::Base
- acts_as_authentic
- acts_as_gmappable
- validates_presence_of :country, :city, :street, :message => 'must be filled'
- has_many :propose
- def gmaps4rails_address
- address
- #describe how to retrieve the address from your model, if you use directly a db column, you can dry your code, see wiki
- #"#{self.street}, #{self.city}, #{self.country}"
- end
- end
- <%= @user.name %>
- <%= @user.email %>
- <%= gmaps4rails(@json) %>
- <%= yield :scripts %>
- <%= render 'layouts/comment' %>
Add Comment
Please, Sign In to add comment