We're using Rails 4, PostgreSQL 9.3.4, and PostGIS 2.1.2.
createdb -E UTF8 template_postgis
createlang -d template_postgis plpgsq
psql -d template_postgis -c "CREATE EXTENSION postgis WITH SCHEMA public;"
| module Test | |
| extend self | |
| def name | |
| @name ||= "My name" | |
| end | |
| def read | |
| @name | |
| end |
| class UserController < ApplicationController | |
| def create | |
| @user = User.new(user_params) | |
| respond_to do |format| | |
| if @user.save | |
| ... | |
| else | |
| ... | |
| end |
| require 'ostruct' | |
| require 'yaml' | |
| # | |
| # A quick and dirty example of something that could be inside of rails to provide | |
| # a stupid simple mock for a model object that has an associated fixture. | |
| # | |
| # ==== Example | |
| # |
| # Demo Database Object Schema: | |
| # | |
| # * name, string | |
| # * status, integer | |
| # * created_at, datetime | |
| # * updated_at, datetime | |
| # | |
| class Demo < ActiveRecord::Base | |
| include BaseScopes | |
| class Geo | |
| def self.get(coords) | |
| sql = <<-EOF | |
| SELECT ST_AsText(ST_GeomFromGeoJSON('{"type":"Polygon","coordinates":#{coords}}')) | |
| EOF | |
| ActiveRecord::Base.connection.execute(sql) | |
| end | |
| end |
| MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | |
| MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | |
| MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | |
| MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | |
| MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | |
| MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMOI+IZDMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | |
| MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM8=+++++++I7DMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM | |
| MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM+++++++++++777$MMMMMMMMMMMMMMMMMMMMMMMMMMMMM | |
| MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM++++++++++++?7777MMMMMMMMMMMMMMMMMMMMMMMMMMMM |
| $(document).watermark( | |
| // "position" : "bottom-right", | |
| // "opacity" : 30, | |
| // "className" : "watermark", | |
| "path": "/assets/watermark.png" | |
| ); |
| # MODEL | |
| class Case < ActiveRecord::Base | |
| include Eventable | |
| has_many :tasks | |
| concerning :Assignment do | |
| def assign_to(new_owner:, details:) | |
| transaction do |