This file contains hidden or 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
<% for i in 1..1000 %> | |
joe_<%= i %>: | |
login: joe_<%= i %> | |
email: joe_<%= i %>@example.com | |
salt: 356a192b7913b04c54574d18c28d46e6395428ab # SHA1('0') | |
crypted_password: 6480dd200db2719d431c7a25b133887ad8b46551 # 'monkey' | |
created_at: <%= 5.days.ago.to_s :db %> | |
activated_at: <%= 5.days.ago.to_s :db %> | |
state: active | |
invitation: <%= Fixtures.identify("#{i}_invite") %> |
This file contains hidden or 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 Specialty < ActiveRecord::Base | |
named_scope :all_by_popularity, | |
:select => 'specialties.*, count(specialties.id) AS c', | |
:joins => :stores, | |
:group => 'specialties.id', | |
:order => 'c DESC' | |
end |
This file contains hidden or 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 Group | |
include DataMapper::Resource | |
# ... no need to paste everything, right? | |
has n, :users, :through => Resource | |
end |
This file contains hidden or 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
# 1) Point *.example.com in your DNS setup to your server. | |
# | |
# 2) Setup an Apache vhost to catch the star pointer: | |
# | |
# <VirtualHost *:80> | |
# ServerName *.example.com | |
# </VirtualHost> | |
# | |
# 3) Set the current account from the subdomain | |
class ApplicationController < ActionController::Base |
This file contains hidden or 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
>> problems.size | |
=> 99 | |
>> problems.include? "a bitch" | |
=> false |
This file contains hidden or 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
desc "Run with same args as db:fixtures:load, but uses semi-sequential IDs" | |
task :load_fixtures => :environment do | |
require 'active_record/fixtures' | |
class Fixtures | |
def self.identify(label) | |
@@id_lookups ||= {} | |
@@id_lookups[label] ||= @@id_lookups.size + 1 | |
end | |
end |
This file contains hidden or 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
# Template which configures a generic Rails app with Shoulda, Factory Girl, | |
# HAML, etc while commiting each step into git. | |
# | |
# Make sure you have Rails 2.3rc1 or greater installed and run: | |
# rails -d mysql -m http://gist.github.com/raw/57458/06345c42a92048e699af3140ccd28bbcd8915bc5/archfear.rb my_app | |
# Helper methods | |
def environment(data = nil, options = {}, &block) | |
options = { :sentinel => 'Rails::Initializer.run do |config|' }.merge(options) |
This file contains hidden or 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
def ordinalize(i) | |
words = ['zeroth', 'first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth', 'eleventh', 'twelth', 'thirteenth', 'fourteenth', 'fifteenth', 'sixteenth', 'seventeenth', 'eighteenth', 'nineteenth'] | |
deca_prefixes = {20 => 'twenty', 30 => 'thirty', 40 => 'forty', 50 => 'fifty', 60 => 'sixty', 70 => 'seventy', 80 => 'eighty', 90 => 'ninety'} | |
return words[i] unless i >= words.size | |
suffix = i % 10 | |
prefix = i - suffix | |
return deca_prefixes[prefix].chop.concat('ieth') if suffix == 0 | |
return deca_prefixes[prefix] + '-' + words[suffix] | |
end |
This file contains hidden or 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
<!-- app/views/project_roles/_form.html.erb --> | |
<div class="projectRole"> | |
<%= form.label :name %> | |
<%= form.text_field :name %> | |
<!-- etc etc etc --> | |
<!-- the JS down below relies on the following two lines being next to each other --> | |
<%= form.hidden_field '_destroy' unless form.object.new_record? %> | |
<a href="#" class="removeNestedItem">Delete</a> |
This file contains hidden or 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
module DealsHelper | |
def render_deals | |
Deal.all.collect do |deal| | |
content_tag :div, :class => 'deal' do | |
image_tag(deal.photo_url) | |
content_tag :h3, deal.title, :class => 'title' | |
content_tag :p, deal.full_price, :class => 'full_price' | |
content_tag :p, deal.selling_price, :class => 'selling_price' | |
content_tag :p, deal.discount, :class => 'discount' | |
content_tag :p, deal.store.name, :class => 'store_name' |
OlderNewer