Skip to content

Instantly share code, notes, and snippets.

View Lordnibbler's full-sized avatar

Ben Radler Lordnibbler

View GitHub Profile
{
"channels": {
"78": {
"name": "Zombie Bass",
"num_of_listeners": 1,
"created_at": "2012-03-21T04:04:36Z",
"updated_at": "2012-04-20T01:21:12Z"
},
"82": {
"name": "The Beatles123",
{
"channels": [
{
"number": 78,
"name": "Zombie Bass",
"num_of_listeners": 1,
"created_at": "2012-03-21T04:04:36Z",
"updated_at": "2012-04-20T01:21:12Z"
},
]
{
"channels": [
{
"number": 78,
"name": "Zombie Bass",
"num_of_listeners": 1,
"created_at": "2012-03-21T04:04:36Z",
"updated_at": "2012-04-20T01:21:12Z"
},
{
RKObjectMapping* channelMapping = [RKObjectMapping mappingForClass:[Channel class]];
[channelMapping mapKeyPath:@"id" toAttribute:@"identifier"];
[channelMapping mapKeyPath:@"name" toAttribute:@"name"];
[channelMapping mapKeyPath:@"num_of_listeners" toAttribute:@"numOfListeners"];
//object mapping for GETs
[[RKObjectManager sharedManager].mappingProvider setMapping:channelMapping forKeyPath:@"channels"];
//set up object serialization for POSTing back to rails
RKObjectMapping* channelSerializationMapping = [channelMapping inverseMapping];
{
"channels": {
"channel_78": {
"name": "Zombie Bass",
"num_of_listeners": 1,
"created_at": "2012-03-21T04:04:36Z",
"updated_at": "2012-04-20T01:21:12Z"
},
"channel_82": {
"name": "The Beatles123",
- (void)setupObjectMapping {
// RKObjectMapping* channelMapping = [RKObjectMapping mappingForClass:[Channel class]];
// [channelMapping mapKeyPath:@"id" toAttribute:@"identifier"];
// [channelMapping mapKeyPath:@"name" toAttribute:@"name"];
// //[channelMapping mapKeyPath:@"created_at" toAttribute:@"createdAt"];
// //[channelMapping mapKeyPath:@"updated_at" toAttribute:@"updatedAt"];
// [channelMapping mapKeyPath:@"num_of_listeners" toAttribute:@"numOfListeners"];
RKObjectMapping* channelMapping = [RKObjectMapping mappingForClass:[Channel class] ];
channelMapping.forceCollectionMapping = YES;
RewriteCond %{HTTP_HOST} ^store.site.com [OR]
RewriteCond %{HTTP_HOST} ^www.store.site.com
RewriteRule ^(.*)$ http://site.com [R=301,L]
require 'test_helper'
class PostTest < ActiveSupport::TestCase
test "the truth" do
assert_equal true, true
end
end
Authentication Load (0.2ms) SELECT `authentications`.* FROM `authentications` WHERE `authentications`.`user_id` = 17 LIMIT 1
(0.4ms) SELECT ig_id FROM `comments` WHERE `comments`.`post_id` = 1443
User Load (0.3ms) SELECT `users`.* FROM `users` LIMIT 1
#post_test.rb
should "add points to post.user when updating title" do
@user = FactoryGirl.create(:user)
@post = FactoryGirl.create(:post, :title => nil, :story => nil, :user_id => @user.id)
pts_before = @user.points
@post.update_attributes(:title => "new title")
pts_after = @user.points
assert_not_equal(pts_before, pts_after)
#user's points == 10 here, even though it JUST showed 12 inside the post#add_points method
end