Skip to content

Instantly share code, notes, and snippets.

View cmeiklejohn's full-sized avatar
💭
Always working.

Christopher S. Meiklejohn cmeiklejohn

💭
Always working.
View GitHub Profile
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new # guest user
if user.role? :admin
can :manage, :all
else
can :read, :all
@alexg0
alexg0 / installing_jruby_on_ubuntu.sh
Created November 27, 2009 19:18
Installing jruby on ubuntu
# get current jruby
wget http://jruby.kenai.com/downloads/1.4.0/jruby-bin-1.4.0.tar.gz
tar xzvf jruby-bin-1.4.0.tar.gz
sudo mv jruby-1.4.0/ /opt
# link executables in /usr/local/bin
sudo ln -s /opt/jruby-1.4.0/bin/{jgem,jirb,jruby} /usr/local/bin
@lancejpollard
lancejpollard / Rails Nested Forms with belongs_to
Created January 13, 2010 23:09
Rails Nested Forms with belongs_to, doesn't work by default
# user.rb
class User < ActiveRecord::Base
belongs_to :address
accepts_nested_attributes_for :address # can't have allow_destroy
end
# users_controller.rb
class UsersController < ApplicationController
ouvasam # Hello Using ripple is there something to delete an embedded document
seancribbs # ouvasm: one or many?
ouvasam # many
]seancribbs # the association proxies an array, so you should be able
to do doc.embedded_docs.delete(embedded_doc)
ouvasam # thanks, but using a html form, how can i retrieve the embedded doc ?

##Enlight Solutions Seeks a Rubyist That Wants to Learn##

Are you looking for a part time ruby gig (15-20 hours / week)? Come learn and grow with Enlight Solutions. It's a great opportunity to improve your coding skills and create awesome applications. This could eventually turn out to be a full time, salaried position.

If you're interested, please send me your github account, references, hourly rate, and/or code samples (in lieu of a github account). Resumes are great, but practical application and endorsements from your peers or clients will secure the position.

###You will:###

  • Learn design patterns and architectural techniques that will serve you greatly in the future
  • Learn Rails 3
set nocompatible
set number
set ruler
syntax on
" Whitespace stuff
set nowrap
set tabstop=2
set shiftwidth=2
@derencius
derencius / utf8_header.rb
Created February 3, 2011 19:05 — forked from francesc/utf8encode.rake
thor file to add utf-8 header on ruby files. useful for converting ruby 1.8 projects to 1.9
class Utf8Header < Thor
desc "add", "Add Content UTF-8 on top of all .rb/.feature files"
# copy & pasted from https://gist.github.com/738245
def add
files = Array.new
["*.rb", "*.rake","*.feature"].each do |extension|
files.concat(Dir[ File.join(Dir.getwd.split(/\\/), "**", extension) ])
end
files.each do |file|
@tenderlove
tenderlove / person_test.rb
Created February 10, 2011 23:04
Use minitest/spec with Rails 3
require 'test_helper'
require 'minitest/autorun'
module Tenderlove
class Spec < MiniTest::Spec
include ActiveSupport::Testing::SetupAndTeardown
include ActiveRecord::TestFixtures
alias :method_name :__name__ if defined? :__name__
self.fixture_path = File.join(Rails.root, 'test', 'fixtures')
@jraines
jraines / rails31init.md
Created May 24, 2011 17:03
Rails 3.1 with Rspec, Cucumber, Factory Girl, Haml, and Simple Form

Install Rails 3.1 RC

gem install rails --pre

generate new app, skipping Test::Unit file generation

rails new my_app -T

Set up Gemfile