Posts

Showing posts from February, 2020

Easy Way of Finding Coordinates in Polygon

Image
(Ruby on Rails 6 only API, Postgres, Minitest) Hi everybody, Sometimes, we need specific features in our application. One of them may be “How to find Coordinates in Polygon” :) We suppose, we have some areas in our application. We define these areas by using Google Maps and every area has some specific attributes that are name , price, and coordinates. For example, we need information like this, when we click on a point on the map, what are the properties of this point? How to find if the dots are between the corresponding coordinates? GEMS If we are using Ruby on Rails, we think firstly that “is there any Gem about finding these points? Yes, there are some Gems. Like : https://github.com/geokit/geokit https://github.com/apneadiving/Google-Maps-for-Rails https://github.com/alexreisner/geocoder But these gems little huge :) Actually, we don’t need to use completely a gem. Because we just find a point in a polygon, technically. There is a cost of a gem for our a

More Performance in Cancancan

Image
If you use Ruby On Rails, you probably % 90 know Cancancan gem when you need some authorization and ability. Generally, in the first times experiences everything might be easy. When you start a basic application everything very fast and basic in Rails application. When you added some modules and features can be a little hard to manage your application. After 1 year, if your company or your application still living, you start to think of Rails application performance. You start to fix N+1 problems. You start to improve Active Record Queries. I am seeing to hear your words, why this request takes 5 seconds. :) You start to use the caching mechanism. (For Rails caching  https://guides.rubyonrails.org/caching_with_rails.html ). Run queries by controls and paths And if you start to think, why there are a lot of DB Queries in logs. If you use Cancancan gem, you need caching role queries and some (if) cases according to by request paths, controllers. I’ll try to inform you a