geokit

Update geocode latitude and longitude everytime address is updated

萝らか妹 提交于 2019-12-07 20:09:37
问题 I have this in my shop.rb : def geocode_address if !address_geo.blank? geo=Geokit::Geocoders::MultiGeocoder.geocode(address_geo) errors.add(:address, "Could not Geocode address") if !geo.success self.lat, self.lng = geo.lat,geo.lng if geo.success end end # Checks whether this object has been geocoded or not. Returns the truth def geocoded? lat? && lng? end And in my shops_controller.rb : def update @shop = Shop.find(params[:id]) if @shop.update_attributes(params[:shop]) flash[:notice] =

Geokit in Ruby on Rails, problem with acts_as_mappable

末鹿安然 提交于 2019-12-06 13:06:17
i have looked through the list of related questions however my problem does not seem to be listed and hence here it is: Basically I'm trying to use Geokit within the Ruby on Rails environment, im not sure if i installed it properly, I have included it within the environment.rb (and done rake db:install) and i'm now trying to do the following: require 'active_record' require 'geokit' class Store < ActiveRecord::Base acts_as_mappable end Unforunately, when i try to run this and see if its ok, i get the following error: c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb

Using Rails 3 with Geokit-rails3 location gem

徘徊边缘 提交于 2019-12-05 22:56:55
I am trying to use the geokit-rails3 gem for geolocation information in a rails application. I have a simple model: class Location < ActiveRecord::Base def lookup_ip_information(post_ip) ip = post_ip location = IpGeocoder.geocode(ip) puts location.full_address lat = location.lat lng = location.lng end end When I call this method with request.remote_ip from my controller, it's throwing an error: uninitialized constant Location::IpGeocoder I just had this issue and resolved it by entering the full Geokit::Geocoders::IpGeocoder.geocode(request.remote_ip) and that seemed to solve it for me. Had

Rails 3.1.0, geokit, with error acts_as_mappable

青春壹個敷衍的年華 提交于 2019-12-02 07:01:13
I am getting the undefined local variable or method `acts_as_mappable' error when using geokit, and after tons of Goggling and attempts, I cannot seem to be able correct the problem. Basically, I have the following gems installed: geokit (1.6.0, 1.5.0) geokit-rails31 (0.1.3) and have the following in my model class House < ActiveRecord::Base acts_as_mappable end and Gemfile: gem 'geokit', '>= 1.5.0' gem 'geokit-rails31' I get the error with or without doing the following in my local app. rails plugin install git://github.com/jlecour/geokit-rails3.git Okay - Here is the solution for anyone that

Change value of request.remote_ip in Ruby on Rails

跟風遠走 提交于 2019-11-30 12:26:20
For test purposes I want to change the return value of request.remote_ip. While being on my development machine it returns always 127.0.0.1 as it should but I would like to give myself different fake IPs to test the correct behavior of my app without deploying it to an live server first! Thank you. Veger If you want this functionality in your whole application, it might be better/easier to override the remote_ip method in your app/helpers/application_helper.rb : class ActionDispatch::Request #rails 2: ActionController::Request def remote_ip '1.2.3.4' end end And the 1.2.3.4 address is

Combine arrays of conditions in Rails

懵懂的女人 提交于 2019-11-29 02:44:46
I'm using the Rails3 beta, will_paginate gem, and the geokit gem & plugin. As the geokit-rails plugin, doesn't seem to support Rails3 scopes (including the :origin symbol is the issue), I need to use the .find syntax. In lieu of scopes, I need to combine two sets of criteria in array format: I have a default condition: conditions = ["invoices.cancelled = ? AND invoices.paid = ?", false, false] I may need to add one of the following conditions to the default condition, depending on a UI selection: #aged 0 lambda {["created_at IS NULL OR created_at < ?", Date.today + 30.days]} #aged 30 lambda {[