View users_controller.rb
class UserController < ApplicationController
def create
@user = User.new(user_params)
respond_to do |format|
if @user.save
...
else
...
end
View fixture_mock.rb
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
#
View demo.rb
# Demo Database Object Schema:
#
# * name, string
# * status, integer
# * created_at, datetime
# * updated_at, datetime
#
class Demo < ActiveRecord::Base
include BaseScopes
View LocalTimezoneDatabase.mkd

Installing and Setting a Timezone database

We're using Rails 4, PostgreSQL 9.3.4, and PostGIS 2.1.2.

Creating a Postgis enabled Postgresql template

createdb -E UTF8 template_postgis
createlang -d template_postgis plpgsq
psql -d template_postgis -c "CREATE EXTENSION postgis WITH SCHEMA public;"
View geo.rb
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
View gist:9961560
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMOI+IZDMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM8=+++++++I7DMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM+++++++++++777$MMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM++++++++++++?7777MMMMMMMMMMMMMMMMMMMMMMMMMMMM
View sample.js
$(document).watermark(
// "position" : "bottom-right",
// "opacity" : 30,
// "className" : "watermark",
"path": "/assets/watermark.png"
);
View reshaping_the_command_approach.rb
# MODEL
class Case < ActiveRecord::Base
include Eventable
has_many :tasks
concerning :Assignment do
def assign_to(new_owner:, details:)
transaction do
View app_settings.rb
module AppSettings
class Railtie < Rails::Railtie
config.settings = ::ActiveSupport::OrderedOptions.new
end
end