Ruby on Rails depends on the Ruby programming language (doh), so we need to install that first. Follow the Ruby Setup guide to install a local version of Ruby.
Install the latest version of Rails
Ruby on Rails depends on the Ruby programming language (doh), so we need to install that first. Follow the Ruby Setup guide to install a local version of Ruby.
Install the latest version of Rails
def calc(arr) | |
arr[0] + (13.0 * arr[1] / arr[2]) + arr[3] + (12 * arr[4]) - arr[5] + (arr[6].to_f * arr[7] / arr[8]) | |
end | |
def solutions | |
[1,2,3,4,5,6,7,8,9].permutation.to_a.keep_if { |p| calc(p) == 87.0 } | |
end |
def self.within_range(range_km, lat, lng) | |
if lat.present? && lng.present? | |
joins(location: :point) | |
.where( | |
"ST_DWithin(Geography(ST_MakePoint(longitude, latitude)), | |
Geography(ST_MakePoint(#{lng}, #{lat})), | |
#{(range_km * 1000).to_i})" | |
) | |
else | |
none |
We first need a Ruby version manager, we'll use rbenv in this guide. To install rbenv, follow all 5 steps from here: https://github.com/rbenv/rbenv#basic-github-checkout.
Now that we have rbenv and the ruby-build plugin installed, we can start installing Ruby.