Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Scopes with Arel st_functions #61

Open
keithdoggett opened this issue Dec 10, 2020 · 0 comments
Open

Create Scopes with Arel st_functions #61

keithdoggett opened this issue Dec 10, 2020 · 0 comments
Labels

Comments

@keithdoggett
Copy link
Member

It should be possible to create scopes on ActiveRecord models from the SpatialNamedFunctions. This would be in an optional module a user could include into their ActiveRecord model and it would allow access to these scopes.

This would make the SpatialNamedFunctions more accessible for users that are unfamiliar with Arel.

This would allow you to go from this:

pt = RGeo::Geos.factory.point(1,2)
locations = Location.arel_table
Location.select(:id, :geom).where(locations[:geom].st_contains(pt))

to:

pt = RGeo::Geos.factory.point(1,2)
Location.select(:id, :geom).st_contains(:geom, pt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant