This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DownloadsController < ApplicationController | |
before_filter :can_create?, :only => [:new, :create] | |
before_filter :can_edit?, :only => [:edit, :update, :destroy] | |
resources_controller_for :downloads | |
helper_method :can_create?, :can_edit? | |
def can_create? | |
return !!(current_user && current_user.superuser?) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Goal is => Client.first.items... Can do with finder_sql, but want an activerecord way! | |
class Client < ActiveRecord::Base | |
has_many :contacts | |
has_many :tasks, :through => :contacts | |
has_many :items, :through => :contacts # THIS DOESNT WORK | |
end | |
class Contact < ActiveRecord::Base | |
belongs_to :client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Recursion | |
# I usually put them around method arguments | |
def recursive(x) | |
return if x >= 10 | |
puts x | |
recursive x + 1 | |
end | |
# No Brackets here | |
recursive 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'mysql' | |
require 'sqlite3' | |
def with_mysql | |
db_object = Mysql.init() | |
db_object.real_connect('localhost','things','1234','things') | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Feeds Checker</h1> | |
<% | |
require 'hpricot' | |
require 'open-uri' | |
f1 = open("http://www.commerce.wa.gov.au/feeds/feed1.xml") | |
feed = Hpricot.XML(f1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra/base' | |
class Bacon < Sinatra::Base | |
enable :logging, :clean_trace | |
get '/' do | |
'Hello from Sinatra!' | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
if [[ -s "${TM_PROJECT_DIRECTORY}/.rvmrc" ]] | |
then | |
source "${TM_PROJECT_DIRECTORY}/.rvmrc" | |
fi | |
exec ruby "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set :default_environment, { | |
'PATH' => '/home/joey/.rvm/gems/ree-1.8.7-2010.02@vk/bin:/home/joey/.rvm/gems/ree-1.8.7-2010.02@global/bin:/home/joey/.rvm/rubies/ree-1.8.7-2010.02/bin:/home/joey/.rvm/bin:$PATH', | |
'RUBY_VERSION' => 'ree-1.8.7-2010.02', | |
'GEM_HOME' => '/home/joey/.rvm/gems/ree-1.8.7-2010.02@vk', | |
'GEM_PATH' => '/home/joey/.rvm/gems/ree-1.8.7-2010.02@vk:/home/joey/.rvm/gems/ree-1.8.7-2010.0@global', | |
'BUNDLE_PATH' => '/home/joey/.rvm/gems/ree-1.8.7-2010.02@vk' # If you are using bundler. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
source "$HOME/.rvm/scripts/rvm" | |
if command -v __rvm_load_rvmrc >/dev/null; then | |
__rvm_load_rvmrc | |
fi | |
exec ruby "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
source ~/.rvm/scripts/rvm | |
! command -v ruby >/dev/null 2>&1 || command -v ruby | grep -v rvm >/dev/null | |
echo "Result = $?" | |
echo "<pre>" | |
echo "rvm_path = '$rvm_path'" | |
echo "$rvm_environments_path" | |
echo "---" | |
rvm alias list | |
echo "--" |
OlderNewer