Skip to content

Instantly share code, notes, and snippets.

View don-smith's full-sized avatar
🧘

Don Smith don-smith

🧘
  • HYPR
  • Auckland, NZ
View GitHub Profile
@don-smith
don-smith / rails_heroku_mongohq_template.rb
Created May 17, 2010 07:13 — forked from banker/Rails MongoMapper Template.rb
a rails mongo_mapper template when using heroku's mongohq addin
# rails_heroku_mongohq_template.rb
#
# fork of Kyle Banker's Rails MongoMapper Template (http://gist.github.com/219223)
# and modified to work with heroku's mongohq addon.
#
# To use:
# rails project_name -m http://gist.github.com/403483.txt
# (preface with 'sudo' if you think you might need some gems)
# remove unneeded defaults
development: &global_settings
database: textual_development
host: 127.0.0.1
port: 27017
test:
database: textual_test
<<: *global_settings
production:
#!/bin/bash
# To uninstall all gems
GEMS=`gem list --no-versions`
for x in $GEMS ; do gem uninstall $x; done
# In a future revision it would be
# nice to prevent all the prompts but it's
# still faster than the alternative as it is
Using the default profile...
no such file to load -- action_controller/test_process (LoadError)
/Users/don/.rvm/gems/ruby-1.8.7-p299@lemmego/gems/activesupport-3.0.0.rc/lib/active_support/dependencies.rb:219:in `require'
/Users/don/.rvm/gems/ruby-1.8.7-p299@lemmego/gems/activesupport-3.0.0.rc/lib/active_support/dependencies.rb:219:in `require'
/Users/don/.rvm/gems/ruby-1.8.7-p299@lemmego/gems/activesupport-3.0.0.rc/lib/active_support/dependencies.rb:207:in `load_dependency'
/Users/don/.rvm/gems/ruby-1.8.7-p299@lemmego/gems/activesupport-3.0.0.rc/lib/active_support/dependencies.rb:219:in `require'
/Users/don/.rvm/gems/ruby-1.8.7-p299@lemmego/gems/rspec-rails-1.3.2/lib/spec/rails.rb:8
/Users/don/.rvm/gems/ruby-1.8.7-p299@lemmego/gems/activesupport-3.0.0.rc/lib/active_support/dependencies.rb:219:in `require'
/Users/don/.rvm/gems/ruby-1.8.7-p299@lemmego/gems/activesupport-3.0.0.rc/lib/active_support/dependencies.rb:219:in `require'
/Users/don/.rvm/gems/ruby-1.8.7-p299@lemmego/gems/activesupport-3.0.0.rc/lib/activ
require 'rspec'
class MaterialSelector
def select(model, material)
model.selection.clear
model.entities.each do |entity|
select_with entity, material do |matching_entity|
model.selection.add matching_entity
end
class Event < ActiveRecord::Base
has_many :event_users
has_many :producers, :through => :event_users, :source => :user
end
<html>
<head><title><%= yield(:title) %></title></head>
<body>
<h1><%= yield(:title) %></h1>
<%= yield %>
</body>
</html>
# app/views/talks/_form.html.erb
<%= form_for([@event, @talk]) do |f| %>
<% if @talk.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@talk.errors.count, "error") %> prohibited this talk from being saved:</h2>
<ul>
<% @talk.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
(function($){
$.widget("ui.mywidget", {
options: {
autoOpen: true
},
_create: function(){
// by default, consider this thing closed.
@don-smith
don-smith / jquery.ui.widget.js
Created May 18, 2011 03:35
Does destroy need to use both this.element and this.widget()?
...
$.Widget.prototype = {
...
destroy: function() {
this.element
.unbind( "." + this.widgetName )
.removeData( this.widgetName );
this.widget()
.unbind( "." + this.widgetName )
.removeAttr( "aria-disabled" )