Created
April 20, 2011 17:40
Revisions
-
danreedy revised this gist
Apr 20, 2011 . 3 changed files with 30 additions and 21 deletions.There are no files selected for viewing
Empty file.This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ class Place < ActiveRecord::Base after_save :create_simplegeo_record private def create_simplegeo_record begin record = SimpleGeo::Record.new({ :id => self.id, :created => Time.now, :lon => self.longitude, :lat => self.latitude, :layer => 'com.getcoke.testdata', :properties => { :name => self.place_name, :notes => self.notes, :address => self.address, :city => self.city, :state => self.state, :zip => self.zip } }) SimpleGeo::Client.add_record(record) rescue => e # Doing nothing here, but I would add some error checking end end end This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,29 +1,9 @@ def create @place = Place.new(params[:place]) if @place.save respond_with(@place) do |format| format.html { redirect_to( @place, :notice => "Great, this coke was saved!" ) } end else render :action => :new -
danreedy created this gist
Apr 20, 2011 .There are no files selected for viewing
Empty file.This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ def create @place = Place.new(params[:place]) new_was_successful = @place.save if new_was_successful respond_with(@place) do |format| format.html { redirect_to( @place, :notice => "Great, this coke was saved!" ) } record = SimpleGeo::Record.new({ :id => @place.id, :created => Time.now, :lon => params[:place][:longitude], :lat => params[:place][:latitude], :layer => 'com.getcoke.testdata', :properties => { :name => params[:place][:"place_name"], :notes => params[:place][:notes], :address => params[:place][:address], :city => params[:place][:city], :state => params[:place][:state], :zip => params[:place][:zip] } }) SimpleGeo::Client.add_record(record) end else render :action => :new end end