Skip to content

Instantly share code, notes, and snippets.

@jachenry
jachenry / _child_fields.html.erb
Created October 18, 2012 02:13
Hierarchical Nested Form
<%= f.text_area :label, :rows => 2%>
<%= field_set_tag 'Answers' do %>
<%= f.fields_for :answers do |af| %>
<%= af.text_field :label %>
<%= af.collection_select(:followup_id, f.object.children, :id, :label, :include_blank => true) %>
<%= af.link_to_remove 'X', :class => 'radius button'%>
<% end %>
<%= f.link_to_add "Add Answer", :answers%>
@jachenry
jachenry / template_handler.rb
Created October 11, 2012 04:06
SCSS Template Handler
require 'sass/plugin'
module Sass
module Rails
class TemplateHandler
class_attribute :default_format
self.default_format = Mime::CSS
def initialize
end
window.addEventListener "DOMContentLoaded", ->
body = $ "body"
canvas = $ "#canvas"
chalkboard = $ "#chalkboard"
close = $ "#close"
ledge = $ "#ledge"
lightswitch = $ "#lightswitch"
output = $ "#output"
shade = $ "#shade"
share = $ "#share"
(function(Spine, $){
var createCollection = function(model, record){
var collection = model.setup(model.name, model.attributes);
collection.extend(Spine.Model.Ajax);
collection.extend({
url: function(){
return record.url() + "/" + this.name.toLowerCase() + "s"
}
});
localhost:repos jacob$ which node
/usr/local/bin/node
localhost:repos jacob$ node -v
v0.4.7
localhost:repos jacob$ which npm
/usr/local/bin/npm
localhost:repos jacob$ npm -v
class UsersController < ApplicationController
# GET /users
# GET /users.xml
# GET /users.fxml
def index
@users = User.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @users }