Skip to content

Instantly share code, notes, and snippets.

@danreedy
Created April 20, 2011 17:40
Show Gist options
  • Save danreedy/932095 to your computer and use it in GitHub Desktop.
Save danreedy/932095 to your computer and use it in GitHub Desktop.
Original Places Controller create method
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
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
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment