geokit / geokit-rails

Official Geokit plugin for Rails/ActiveRecord. Provides location-based goodness for your Rails app. Requires the Geokit gem.
MIT License
1.57k stars 245 forks source link

Select columns does not work ( :select=>'field1,field2')! #7

Closed xpepermint closed 3 years ago

xpepermint commented 14 years ago

Example:

Model 1

class Point < ActiveRecord::Base belongs_to :imageable, :polymorphic => true acts_as_mappable end

Model 2

class Product < ActiveRecord::Base has_many :points, :as => :imageable acts_as_mappable :through => :points end

Controller

class ProductsController < ApplicationController def near @products = Product.all(:include => :points, :select => "title", :origin => origin, :within => distance) respond_to do |format| format.xml { render :xml => @products.to_xml(:include => :points) } end end end

Using :select => "title" does not work - the rule is ignored (all fields are selected not just title).

ryankopf commented 3 years ago

One alternative is to use pluck (:title)

I am closing all issues that are more than 6 years old now, as the gem has had significant updates and is likely people with these old issues are no longer having the issues. If you are currently still experiencing this issue or need help feel free to submit a new issue, thank you.