Skip to content

Instantly share code, notes, and snippets.

View JohnAmican's full-sized avatar
🎯
Focusing

John Amicangelo JohnAmican

🎯
Focusing
View GitHub Profile
class Classroom < ActiveRecord::Base
belongs_to :school
attr_accessible :code, :name, :school_id
validates :code, :name, :school_id, :presence => true
def school_name
school.name
end
<!DOCTYPE html>
<html lang="en">
<head>
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Beth's Page</title>
</head>
<body>
<div class="container">
<!-- Ex. two column layout -->
module BeforeRender
extend ActiveSupport::Concern
included do
define_callbacks :render
end
def render(*args, &block)
run_callbacks(:render) do
super
bundle = (name, opts) ->
_.extend opts,
fullPaths: true
cache: {}
packageCache: {}
b = browserify opts
rebundle = ->
b.bundle()
gulp.task 'frontend-js', ->
bundle 'application.js',
entries: ["your/entry/file.cjsx"] # or `.coffee` or whatever
extensions: ['.coffee', '.cjsx']
debug: true
bundle 'server.js',
entries: ["your/entry/file.cjsx"]
extensions: ['.coffee', '.cjsx']
builtins: false # already in node
commondir: false # already in node
detectGlobals: false # already in node
browserField: false # already in node
standalone: 'render'
module React
module Server
module Rendering
extend ActiveSupport::Concern
include ::BeforeRender
included do
before_render :set_rendered
attr_reader :rendered
React = require 'react'
app = require './app'
module.exports = (data) -> React.renderToString app(data)
CREATE UNIQUE INDEX trades_root_id_and_version ON trades (root_id, version);
CREATE TABLE trades
(
id SERIAL NOT NULL CONSTRAINT trades_pkey PRIMARY KEY,
latest BOOLEAN NOT NULL,
root_id TEXT NOT NULL,
version INTEGER NOT NULL,
price INT
);