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 Foo < ActiveRecord::Base | |
before_create :make_token | |
private | |
TOKEN_SYMBOLS = (('A'..'Z').to_a + ('a'..'z').to_a + (0..9).to_a) | |
def make_token | |
self.token = (1..12).inject(""){|token, num| token += TOKEN_SYMBOLS.rand.to_s } | |
make_token if self.class.find_by_token(self.token) | |
self.token | |
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
class Facebook | |
attr_accessor :user | |
def initialize(user) | |
self.user = user | |
end | |
def post(user, params={}) | |
params = normalize_params(params, %w(message picture link name caption description source)) | |
client = OAuth2::Client.new(app_id, app_secret, :site => 'https://graph.facebook.com/', :parse_json => true) |
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
I, [2010-12-06T09:33:27.030001 #27061] INFO -- : unlinking existing socket=/tmp/.unicorn-socket | |
I, [2010-12-06T09:33:27.030259 #27061] INFO -- : listening on addr=/tmp/.unicorn-socket fd=3 | |
I, [2010-12-06T09:33:27.030806 #27061] INFO -- : Refreshing Gem list | |
/usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.3/lib/bundler/runtime.rb:27:in `setup': You have already activated rack 1.0.1, but your Gemfile requires rack 1.2.1. Consider using bundle exec. (Gem::LoadError) | |
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.3/lib/bundler/spec_set.rb:12:in `each' | |
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.3/lib/bundler/spec_set.rb:12:in `each' | |
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.3/lib/bundler/runtime.rb:17:in `setup' | |
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.3/lib/bundler.rb:100:in `setup' | |
from /var/www/releases/20101206173428/config/boot.rb:8 | |
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' |
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
<% | |
# _counter is defined only if we pass :collection to the partial | |
if defined?(blog_post_counter) | |
showing_individual_post = false | |
else | |
showing_individual_post = true | |
blog_post_counter = 0 | |
end | |
%> | |
<div id="blog_post_<%= blog_post.id %>" class="blog_post"> |
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 TheatresController < ApplicationController | |
def index | |
@theatre = Theatre.all | |
end | |
def new | |
@theatre = Theatre.new(params[:theatre]) | |
end | |
def create |
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 CreateRoles < ActiveRecord::Migration | |
def self.up | |
create_table :roles do |t| | |
t.string :name | |
t.string :role | |
t.timestamps | |
end | |
create_table :user_roles do |t| | |
t.references :user |
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
# Don't change this file! | |
# Configure your app in config/environment.rb and config/environments/*.rb | |
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) | |
module Rails | |
class << self | |
def boot! | |
unless booted? | |
preinitialize |
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
# Edit this Gemfile to bundle your application's dependencies. | |
source 'http://rubygems.org' | |
gem "rails", "2.3.7" | |
#gem "mysql" | |
gem "sqlite3-ruby", :require => "sqlite3" | |
gem "authlogic", '2.1.4' | |
gem "aws-s3", "0.6.2", :require => "aws/s3" |
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
# Use Bundler (preferred) | |
begin | |
require File.expand_path('../../.bundle/environment', __FILE__) | |
rescue LoadError | |
require 'rubygems' | |
require 'bundler' | |
Bundler.setup | |
# To use 2.x style vendor/rails and RubyGems | |
# |
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 Charge < ActiveRecord::Base | |
CHARGE_TYPES = ["upload", "storage", "deposit"] | |
belongs_to :member | |
default_scope :order => "charges.updated_at DESC" | |
validates_presence_of :name, :unit_price, :quantity | |
validates_inclusion_of :charge_type, :in => CHARGE_TYPES | |
validates_inclusion_of :chargeable_type, :in => %w(Payment VideoUpload) | |
NewerOlder