Skip to content

Instantly share code, notes, and snippets.

View jwo's full-sized avatar

Jesse Wolgamott jwo

View GitHub Profile
@jwo
jwo / post.rb
Created October 3, 2012 20:03
Dynamic strong_parameters example
class Post < ActiveRecord::Base
include ActiveModel::ForbiddenAttributesProtection
def self.attributes_for_user user
attrs = [:body, :title]
attrs << :published if user.admin?
attrs
end
end
@jwo
jwo / rule.md
Created August 25, 2012 19:15
Ember + Rails (Houston Code Camp live)

Each year there is a competition… Fake Thanksgiving!

The House provides a turkey, and you enter a side or a dessert. (the entry). Then, people vote. the winner gets fame and glory!

The first year, we voted on paper. The next, I built a Rails 1.2 website that tabulated votes. (updated over time).

Let's build a voting machine with Rails as the API but use Ember to keep state and give a better user experience.

Rails Side

@jwo
jwo / .profile
Created July 16, 2012 02:40
~/.profile rvm settings
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
[[ -r $rvm_path/scripts/completion ]] && . $rvm_path/scripts/completion
rvm use default
@jwo
jwo / alert_finder.sh
Created June 4, 2012 15:04
Print out any UI alerts in your app/views (and next 10 lines).
#!/bin/bash
# Useful for documentation to the client about what alert messages to users you added to the system
# For Rails, obvs, but useful to any app/views directory structure
FILES=$(grep -lr "alert" app/views)
for file_name in $FILES; do
echo "---------------------------------------";
echo $file_name;
echo "---------------------------------------";
@jwo
jwo / .rspec
Created May 24, 2012 01:38 — forked from coreyhaines/.rspec
Loading just active record
--colour
-I app
@jwo
jwo / gist:2775692
Created May 23, 2012 14:54 — forked from johnnygoodman/gist:2772856
Vehicle Class, Make == Instance Variable Dynamic
#-------------------------------------
# this part just to run the specs
#
#
require 'rspec'
class Vehicle; end
# end
#-------------------------------------
#require_relative './vehicle'
@jwo
jwo / gist:2585904
Created May 3, 2012 14:11 — forked from unnitallman/gist:944011
sqlite with activerecord outside rails
require 'active_record'
require 'logger'
ActiveRecord::Base.logger = Logger.new(STDERR)
ActiveRecord::Base.establish_connection(
adapter: "sqlite3",
database: ":memory:"
)
@jwo
jwo / message.rb
Created April 30, 2012 16:13
Sample mailbox delivery code for Ruby Off Rails
class Message
def deliver_to(mailbox)
mailbox.new_mail(self)
end
end
class Mailbox
def initialize
@jwo
jwo / .rspec
Created March 29, 2012 01:04 — forked from coreyhaines/.rspec
Loading just active record
--colour
-I app
@jwo
jwo / admin_domain.rb
Created March 23, 2012 15:09
ActiveAdmin on admin domain
class AdminDomain
def self.matches?(request)
request.subdomain =~ /admin/
end
end