Rails3 syntax - Ruby geokit-rails

I'm trying to migrate to Rails3 syntax. The following query works:

@users = User.find(
  :all,
  :joins => "INNER JOIN profiles AS profiles ON users.id=profiles.user_id",
  :conditions => ["users.disabled = ? AND users.hidden = ?", false, false],
  :include => :profile,
  :origin => ll,
  :units => :miles, 
  :order => order_by
  ).paginate(:per_page => @per_page, :page => params[:page])

If I convert this query to Rails3 syntax using scopes, the query resembles: @users = User.valid.joins(:profile).includes(:profile).order(orderby).paginate(:perpage => @per_page, :page => params[:page])

Question: how do I reference the :units and :origin in this syntax? I've tried a variation of the Rails3 syntax to use scopes and the .find method:

@users = User.valid.joins(:profile).includes(:profile).find(
  :all,
  :origin => ll,
  :units => :miles, 
  :order => order_by
  ).paginate(:per_page => @per_page, :page => params[:page])

but I get an error that reads "Unknown key(s): origin, units".

Is the plugin Rails3 compatible?

Asked Oct 10 '21 04:10
avatar craibuc
craibuc

7 Answer:

The plugin hasn't been updated for Rails3. Frankly I'm surprised you got the query to work (with the old syntax) on Rails3.

I've noodled around a little bit with the Rails3 chainable scopes for the plugin, but nothing to show for it.

1
Answered Jul 15 '10 at 06:01
avatar  of andre
andre

Lucky, I'd guess.

I would offer my help, but I'm too new to Rails to be of much value.

Any ideas on when your plugin will be update for R3?

Thanks for the work you've done so far, BTW.

1
Answered Jul 15 '10 at 12:30
avatar  of craibuc
craibuc

Any ideas on when your plugin will be update for R3?

I'm not personally going to be able to tackle it anytime soon. Would love to see something in the community take it on.

1
Answered Jul 15 '10 at 19:52
avatar  of andre
andre

do you have any ideas on what needs to change? how much work is involved? something a novice could tackle?

1
Answered Jul 16 '10 at 00:56
avatar  of craibuc
craibuc

Has anyone tried this one for Rails 3?

https://github.com/jlecour/geokit-rails

https://rubygems.org/gems/geokit-rails3

It will be a bit before I can upgrade to Rails 3 but would love to hear if anyone out in the wild is finding jlecour's version works.

1
Answered Feb 14 '11 at 09:17
avatar  of triemstr
triemstr

This works for me in Rails 3 and the 'geokit-rails3' gem:

@users = User.valid.joins(:profile).includes(:profile). geoscope(:origin => ll, :within => distance). order(orderby). paginate(:perpage => @perpage, :page => params[:page])

1
Answered Feb 14 '11 at 17:19
avatar  of craibuc
craibuc

Cool, I'm totally going to try it too then in a few weeks when I can move my app to Rails 3. Thanks for checking it out and hope it continues to work for you.

1
Answered Feb 17 '11 at 21:51
avatar  of triemstr
triemstr