Skip to content

Instantly share code, notes, and snippets.

@incorvia
incorvia / engine.rb
Created July 6, 2013 02:43
Railties
# Some requires...
module Rails
class Engine < Railtie
# truncated
def railties
@railties ||= Railties.new
end

Boxen uses a bunch of shellscripts to insert itself into your environment on shell load.

These assume a POSIX shell, which fish is not.

Run this script to generate a fish-compatible config file in ~/.config/fish/boxen.fish, which you can source at the end of your ~/.config/fish/config.fish.

@incorvia
incorvia / gist:5310770
Last active December 15, 2015 19:19
Slim Template syntax example
// FAUX ENV
- body_class = "full-width"
- my_array = *(1..10)
//--------------- MOST HTML LIKE ---------------
doctype html
html
head
meta content="text/html" charset="utf-8" http-equiv="Content-type"
source 'https://rubygems.org'
gem 'rails', '3.2.3'
# Database
gem 'pg'
gem "foreigner"
# Improvements
gem 'inherited_resources'
source 'https://rubygems.org'
gem 'rails', '3.2.3'
# Database
gem 'pg'
gem "foreigner"
# Improvements
gem 'inherited_resources'
@incorvia
incorvia / gist:4356240
Last active December 10, 2015 01:09 — forked from anonymous/gist:4356164
(bad dir) - 50cd74e860de7d6d0b1422bf => http://reviewed-production.s3.amazonaws.com/uploads/tmp/20121221-2155-2-5788/OLYMPUS-E-30-pencil-iso800-NR3-normal.jpg
(staging) - 50cd71bd60de7d6d0b140078 => https://staging.reviewed.attachments.s3.amazonaws.com/attachment/fd4d10a08743b30d949de476a8ff9c2430937b39/NIKON-S630-still-iso64.jpg
(bad dir) - 50cd74f760de7d6d0b142359 => http://reviewed-production.s3.amazonaws.com/uploads/tmp/20121221-2155-2-6205/spacer.gif
(bad dir) - 50cd74fc60de7d6d0b1423a9 => http://reviewed-production.s3.amazonaws.com/uploads/tmp/20121221-2155-2-2233/spacer.gif
(bad dir) - 50cd74ac60de7d6d0b141fcf => http://reviewed-production.s3.amazonaws.com/uploads/tmp/20121221-2154-2-7336/NIKON-D90-left-small.jpg
(bad dir) - 50cd74f560de7d6d0b142344 => http://reviewed-production.s3.amazonaws.com/uploads/tmp/20121221-2155-2-0796/viewfinder3_61.jpg
(bad dir) - 50cd74a360de7d6d0b141f5e => http://reviewed-production.s3.amazonaws.com/uploads/tmp/20121221-2153-2-6083/spacer.gif
(bad dir) - 50cd750460de7d6d0b
/Users/incorvia/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:1257:in `block in compile!': undefined method `website_ids' for Sinatra::Application:Class (NoMethodError)
from /Users/incorvia/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:1257:in `each_pair'
from /Users/incorvia/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:1257:in `compile!'
from /Users/incorvia/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:1239:in `route'
from /Users/incorvia/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:1221:in `get'
from /Users/incorvia/.rvm/gems/ruby-1.9.3-p327/gems/sinatra-1.3.3/lib/sinatra/base.rb:1660:in `block (2 levels) in delegate'
from /Users/incorvia/.rvm/gems/ruby-1.9.3-p327/gems/reviewed-0.1.2/lib/reviewed/utils.rb:16:in `collection_from_response'
from /Users/incorvia/.rvm/gems/ruby-1.9.3-p327/gems/reviewed-0.1.2/lib/reviewed/base.rb:23:in `where'
from /User
# more widget-like tags
{{callout}}
{{/callout}}
{{photo_gallery "attachment1", "attachment2"}}
{{manufacturer_specs_table}}
{{raw_scores_table}}
{{comparison_bars}} *with attributes (space separated) as follows:
title="Neato title"
attribute="name" # manufacturer_spec or raw_score for which we are building bars
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
gem 'haml'
gem 'twitter-bootstrap-rails'
end

In Rails, the model is handled by what’s called an object-relational mapping layer entitled Active Record. This layer allows you to present the data from database rows as objects and embellish these data objects with business logic methods. You can read more about Active Record in files/vendor/rails/activerecord/README.html.