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
## Routes | |
map.add_person '/add_person', :controller => 'people', :action => 'new_unclaimed_person' | |
map.add '/add', :controller => 'people', :action => 'create_unclaimed_person' | |
## People Controller | |
def new_unclaimed_person | |
@person = Person.new |
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
- (void)dealloc { | |
[name release]; | |
[description release]; | |
[super dealloc]; | |
} |
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 Domain < ActiveRecord::Base | |
named_scope :length, lambda {|length| {:conditions => ["length = ?", length]} if !length.blank? || length == 'all'} | |
named_scope :viewable, lambda {{:conditions => ["viewable_at < ?", Time.now.utc]}} | |
named_scope :public, lambda {|public| {:conditions => ["public = ?", true]} if !public.blank?} | |
end | |
def self.search(options = {}) | |
self.length(options[:length]).viewable.public(options[:public]) | |
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
Spec::Matchers.define :require do |attribute| | |
match do |object| | |
factory = object.class.name.downcase.to_sym | |
object = Factory.build(factory, attribute => "") | |
!object.valid? | |
end | |
end | |
describe User do | |
it "should be valid given valid attributes" do |
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
# Finds all setter methods for the object, | |
# builds a new object with these methods set to an arbitrary value, | |
# checks if the given attrs are able to be mass assigned and all others are not, | |
# and finally returns true if there are no failures. | |
Spec::Matchers.define :only_mass_assign_accessible_attributes do |*attrs| | |
match do |object| | |
setters = object.methods.map{|m| m if m.match(/[a-z].*\=$/)}.compact | |
getters = setters.map{|s| s.gsub('=', '').to_sym} | |
params = {} |
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 ScheduleTime | |
attr_reader :seconds, :orig_hour, :hour, :minute, :second | |
def initialize(time, time_of_day) | |
#raise ArgumentError | |
@time = time | |
@time_of_day = time_of_day | |
parse_time | |
end | |
def parse_time |
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 HuzzahsController < ApplicationController | |
before_filter :login_required | |
before_filter :set_twitter_oauth_client | |
def connect | |
request_token = @client.request_token | |
session[:twitter_request_token] = request_token.token | |
session[:twitter_request_token_secret] = request_token.secret | |
redirect_to request_token.authorize_url | |
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
require 'rubygems' | |
require 'sinatra' | |
require 'dm-core' | |
require 'net/http' | |
require 'uri' | |
class ImageModeration | |
include DataMapper::Resource | |
property :id, Integer, :serial=>true | |
property :image_url, Text |
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
map.connect 'questions/:id/:tags/:question', | |
:controller => 'questions', | |
:action => 'show', | |
:tags => 'question', | |
:question => nil | |
module ApplicationHelper | |
def question_path(question, extra_params=true) | |
options = {} |
OlderNewer