Skip to content

Instantly share code, notes, and snippets.

class Entry
attr_accessor :wins
attr_accessor :losses
def initialize
self.wins = 0
self.losses = 0
end
@pt
pt / gist:2966502
Created June 21, 2012 15:39
better responses in rails controllers
class ThingController < ApplicationController
def create_suck
@thing = Thing.new(params[:thing])
respond_to do |format|
if @thing.save
format.html { redirect_to @thing, notice: 'thing was successfully created.' }
format.json { render json: @thing, status: :created, location: @thing }
else
@implementation CappuccinoResource : CPObject
{
}
-(CPString)baseClassName {
if( [super className] == 'CappuccinoResource')
return [self className]
return [super baseClassName]
}
var x = nil;
[CPURLConnection sendSynchronousRequest: aRequest returningResponse: x]
CPLog(aRequest);
CPLog(x);
CPLog(aRequest.responseText)
CPLog(aRequest.status)
# prints
<CPURLRequest 0x001c00>
null
[self assertTrue:CGRectContainsPoint(
CGRectMake(0,0,1,1),
CGPointMake(1,1)
) message:"point should be in rectangle"];
ArrowViewTest.2010-01-26 14:25:57.884 Cappuccino [error]: addError test=[ArrowViewTest test_top_arrow_has_label] error=TypeError: Cannot read property "gState" from null
2010-01-26 14:25:57.891 Cappuccino [error]: at script(/usr/local/narwhal/packages/cappuccino/Frameworks/Debug/AppKit/CGContext.j:217)
at script((Anonymous):46)
at script((Anonymous):16)
at script((Anonymous):29)
at script((Anonymous):55)
at script((Anonymous):24)
at script((Anonymous):109)
at script((Anonymous):70)
at script((Anonymous):57)
- (void)drawRect:(NSRect)aRect {
CPLog("drawing arrow:" + self);
var context = [[CPGraphicsContext currentContext] graphicsPort];
CGContextSetAlpha(context, 1);
CGContextSetStrokeColor(context, [CPColor redColor]);
CGContextMoveToPoint(context,startPoint.x, startPoint.y);
CGContextAddLineToPoint(context, endPoint.x, endPoint.y);
CGContextStrokePath(context);
}
@import "../../models/Wall.j"
[Test for:Wall
beforeAll: function() {
wall = [[Wall alloc] init]
}
checking: function() {
[view setDelegate:mockDelegate];
[mockDelegate selector:@selector(resizePlaceableExclusionZoneView:) times:1];
[self assert:view equals:[button target]];
[self assert:@selector(actionResize:) equals:[button action]];
// If I uncomment out this line, the test passes.
// [view actionResize:nil];
// but if I uncomment this line, the test fails.
[button performClick:nil];
//---------------
// This test:
// --------------
-(void)setUp{
theWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(0,0,200,150)
styleMask:CPWindowNotSizable];
}
-(void)test_set_size_displays_resizer {}