Skip to content

Instantly share code, notes, and snippets.

@croaky
croaky / hoptoad_api.rb
Created July 30, 2008 22:20
Access the Hoptoad (http://hoptoadapp.com) API with Ruby's ActiveResource
# tests at http://gist.github.com/3354
class Hoptoad < ActiveResource::Base
self.site = "http://your_account.hoptoadapp.com"
class << self
@@auth_token = 'your_auth_token'
def find(*arguments)
arguments = append_auth_token_to_params(*arguments)
@croaky
croaky / hoptoad_api_test.rb
Created July 30, 2008 23:19
Tests for Hoptoad API via ActiveResource
# implementation at http://gist.github.com/3350
class HoptoadTest < Test::Unit::TestCase
context 'Error.find :all' do
setup do
@errors = Error.find :all
end
should 'find errors' do
@croaky
croaky / gist:3763
Created August 2, 2008 19:43
"uninitialized constant RubiGen" when running script in Rails 2.1? uninstall sproutcore gem.
dancroak:(git)advantage[master]/$ script/generate controller Categories
uninitialized constant RubiGen
dancroak:(git)advantage[master]/$ sudo gem uninstall sproutcore
Successfully uninstalled sproutcore-0.9.9
dancroak:(git)advantage[master]/$ script/generate controller Categories
create app/views/categories
create app/controllers/categories_controller.rb
create test/functional/categories_controller_test.rb
create app/helpers/categories_helper.rb
irb(main):006:0> :electric_feel ? true : false
=> true
irb(main):007:0> !! :electric_feel
=> true
Processing PhotosController#create (for 127.0.0.1 at 2008-08-10 17:07:55) [POST]
Session ID: d1ffe3154f539e4d29373e729a74b99f
Parameters: {"Filename"=>"n7609878_30799379_1427.jpg", "action"=>"create", "Upload"=>"Submit Query", "controller"=>"photos", "Filedata"=>#<File:/var/folders/Sw/SwOgwsPr2RaQd++F75BRLU+++TI/-Tmp-/CGI.12965.1>}
Photo Columns (0.002088) SHOW FIELDS FROM `photos`
NoMethodError (You have a nil object when you didn't expect it!
The error occurred while evaluating nil.width):
/vendor/plugins/paperclip/lib/paperclip/geometry.rb:79:in `transformation_to'
/vendor/plugins/paperclip/lib/paperclip/thumbnail.rb:61:in `transformation_command'
def create
@photo = Photo.new :image => params[:Filedata]
@photo.save
render :partial => '/photos/show', :locals => { :photo => @photo }
end
class Photo < ActiveRecord::Base
has_attached_file :image,
:styles => { :medium => "500", :small => "150x150#" },
module TimedOutConnection
# overrides the Net::HTTP object
# used by ActiveResource::Connection
def http
http_obj = super
http_obj.open_timeout = 2 # seconds
http_obj.read_timeout = 5 # seconds
http_obj
end
end
@my_cookies = mock('cookies')
@request.stubs(:cookies).returns(@my_cookies)
@my_cookies.expects(:[]=).with(:auth_token).
returns({:value => "value", :expires => 2.weeks.from_now.utc})
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = git@github.com:railsrumble/YOURTEAMNAME.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = git@github.com:railsrumble/YOURTEAMNAME.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin