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 Asset < ActiveRecord::Base | |
acts_as_paranoid | |
def upload_to_s3(file) | |
if file | |
#set content_type | |
content_type = determine_content_type(file) | |
self.content_type = content_type |
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
>> Asset.methods.sort | |
=> [:!, :!=, :!~, :<, :<=, :<=>, :==, :===, :=~, :>, :>=, :__callback_runner_name, :__called_from__, :__define_runner, :__id__, :__reset_runner, :__run_callback, :__send__, :__update_callbacks, :_accessible_attributes, :_accessible_attributes=, :_accessible_attributes?, :_active_authorizer, :_active_authorizer=, :_active_authorizer?, :_attr_readonly, :_attr_readonly=, :_attr_readonly?, :_commit_callbacks, :_commit_callbacks=, :_commit_callbacks?, :_create_callbacks, :_create_callbacks=, :_create_callbacks?, :_define_after_model_callback, :_define_around_model_callback, :_define_before_model_callback, :_destroy_callbacks, :_destroy_callbacks=, :_destroy_callbacks?, :_find_callbacks, :_find_callbacks=, :_find_callbacks?, :_initialize_callbacks, :_initialize_callbacks=, :_initialize_callbacks?, :_mass_assignment_sanitizer, :_mass_assignment_sanitizer=, :_mass_assignment_sanitizer?, :_metasearch_association_authorized?, :_metasearch_attribute_authorized?, :_metasearch_exclude_associations, : |
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)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
if (editingStyle == UITableViewCellEditingStyleDelete) { | |
// Delete the row from the data source | |
Channel *channelToDestroy = [channels objectAtIndex:indexPath.row]; | |
[self destroyChannelWithId:channelToDestroy.identifier]; | |
[super.channels removeObject:channelToDestroy]; | |
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; |
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
2012-03-20 19:28:17.166 Synchronic[40928:fb03] channel: <RKObjectLoader: 0x6e8c710> | |
2012-03-20 19:28:17.167 Synchronic[40928:fb03] -[RKObjectLoader identifier]: unrecognized selector sent to instance 0x6e8c710 | |
2012-03-20 19:28:17.167 Synchronic[40928:fb03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RKObjectLoader identifier]: unrecognized selector sent to instance 0x6e8c710' | |
*** First throw call stack: | |
(0x1c74022 0x1e05cd6 0x1c75cbd 0x1bdaed0 0x1bdacb2 0x3bd4 0x913c54 0x9143ce 0x8ffcbd 0x90e6f1 0x8b7d21 0x1c75e42 0x2a67679 0x2a71579 0x29f64f7 0x29f83f6 0x29f7ad0 0x1c4899e 0x1bdf640 0x1bab4c6 0x1baad84 0x1baac9b 0x204a7d8 0x204a88a 0x879626 0x2972 0x28e5) | |
terminate called throwing an exception |
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
# channels controller | |
def index | |
@channels = Channel.all | |
respond_to do |format| | |
format.html # index.html.erb | |
format.json { render :json => { :channels => @channels } } | |
end | |
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
{"channels":{"78":{"id":78,"name":"Title 1","num_of_listeners":1,"created_at":"2012-03-21T04:04:36Z","updated_at":"2012-04-20T01:21:12Z"},"82":{"id":82,"name":"Title 2","num_of_listeners":1,"created_at":"2012-03-22T20:28:34Z","updated_at":"2012-04-17T04:34:07Z"}}} |
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
{"channels":{"78":{"id":78,"name":"Zombie Bass","num_of_listeners":1,"created_at":"2012-03-21T04:04:36Z","updated_at":"2012-04-20T01:21:12Z"},"82":{"id":82,"name":"The Beatles123","num_of_listeners":1,"created_at":"2012-03-22T20:28:34Z","updated_at":"2012-04-17T04:34:07Z"},"125":{"id":125,"name":"New!","num_of_listeners":1,"created_at":"2012-04-19T04:05:47Z","updated_at":"2012-04-19T04:05:47Z"},"132":{"id":132,"name":"Test!","num_of_listeners":1,"created_at":"2012-04-26T21:00:30Z","updated_at":"2012-04-26T21:00:30Z"}}} |
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)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"]; | |
//object mapping for GETs | |
[[RKObjectManager sharedManager].mappingProvider setMapping:channelMapping forKeyPath:@"channels"]; |
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
{ | |
"channels": { | |
"78": { | |
"id": 78, | |
"name": "Zombie Bass", | |
"num_of_listeners": 1, | |
"created_at": "2012-03-21T04:04:36Z", | |
"updated_at": "2012-04-20T01:21:12Z" | |
}, | |
"82": { |
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
//Channel.h | |
@interface Channel : NSObject <RKRequestDelegate, RKObjectLoaderDelegate> { | |
NSNumber *identifier; | |
NSString *name; | |
NSNumber *numOfListeners; | |
} | |
//AppDelegate.m | |
- (void)setupObjectMapping { | |
RKObjectMapping* channelMapping = [RKObjectMapping mappingForClass:[Channel class]]; |
OlderNewer