小编Kyl*_*e C的帖子

Uncompile Development Asset Pipeline

我正在为我的生产环境编译我的资产管道,它适用于我的所有环境.如何为我的开发环境重新编译资产管道?

我检查了我的配置/开发环境,但找不到修复程序.

在此先感谢任何帮助......

ruby ruby-on-rails ruby-on-rails-3.1 asset-pipeline

43
推荐指数
4
解决办法
2万
查看次数

iOS后台位置不发送http请求

我的应用需要在后台跟踪用户位置,但无法发送"获取"请求.当应用程序到达前台时,会立即发送http请求.我正在使用RestKit来处理所有网络请求,我按照本教程设置了我的后台位置服务.在我的applicationDidEnterBackground中

-(void)applicationDidEnterBackground:(UIApplication *)application
{
    self.bgLocationManager = [[CLLocationManager alloc] init];
    self.bgLocationManager.delegate = self;
    [self.bgLocationManager startMonitoringSignificantLocationChanges];
    NSLog(@"Entered Background");
}
Run Code Online (Sandbox Code Playgroud)

我在applicationDidBecomeActive委托中停止监视有意义的位置变化

这是我的locationManager委托,我接受新的更新位置并发送到我的服务器

-(void) locationManager:(CLLocationManager *)manager 
    didUpdateToLocation:(CLLocation *)newLocation 
           fromLocation:(CLLocation *)oldLocation
{
    NSLog(@"I am in the background");
    bgTask = [[UIApplication sharedApplication]
                beginBackgroundTaskWithExpirationHandler:
                ^{
                      [[UIApplication sharedApplication] endBackgroundTask:bgTask];
                 }];
                 // ANY CODE WE PUT HERE IS OUR BACKGROUND TASK

    NSString *currentLatitude = [[NSString alloc]
                                  initWithFormat:@"%g",
                                  newLocation.coordinate.latitude];
    NSString *currentLongitude = [[NSString alloc]
                                   initWithFormat:@"%g",
                                   newLocation.coordinate.longitude];
    NSString *webToken = [[NSUserDefaults standardUserDefaults] stringForKey:@"userWebToken"];
    NSLog(@"I am in the bgTask, my …
Run Code Online (Sandbox Code Playgroud)

iphone nsurlconnection ios restkit ios5

12
推荐指数
1
解决办法
5073
查看次数

CocoaPods无法使用Xcode 5.0.2进行安装

我已经被困在这个问题上几个小时了,我找不到解决方案.我正在运行Mavericks并安装了Xcode 5.0.2(随命令行工具一起提供).

我的环境:

  • 使用RVM与ruby版本1.9.3p484
  • Xcode 5.0.2
  • Mac OS 10.9.1
  • 宝石2.2.0
  • Bundler版本1.3.5

Sudo gem安装cocoapods输出

kyles-mbp-2:fresh-driver-ios kylechronis$ sudo gem install cocoapods
     Building native extensions.  This could take a while...
     ERROR:  Error installing cocoapods:
     ERROR: Failed to build gem native extension.

    /Users/kylechronis/.rvm/rubies/ruby-1.9.3-p484/bin/ruby -rubygems    
    /Users/kylechronis/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/gems/1.9.1/gems/rake- 0.9.2.2/bin/rake RUBYARCHDIR=/Users/kylechronis/.rvm/rubies/ruby-1.9.3- p484/lib/ruby/gems/1.9.1/extensions/x86_64-darwin-13/1.9.1/xcodeproj-0.14.1 RUBYLIBDIR=/Users/kylechronis/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/gems/1.9.1/extensions/x86_64-darwin-13/1.9.1/xcodeproj-0.14.1

   /Users/kylechronis/.rvm/rubies/ruby-1.9.3-p484/bin/ruby extconf.rb
   checking for -std=c99 option to compiler... yes
   checking for CoreFoundation... no
   checking for main() in -lCoreFoundation... no
   CoreFoundation is needed to build the Xcodeproj C extension.
    *** extconf.rb failed ***
   Could not create …
Run Code Online (Sandbox Code Playgroud)

ruby xcode rubygems cocoapods xcode5

4
推荐指数
1
解决办法
3315
查看次数

Rails重置单列

我正在尝试实现一个每月运行一次以重置单个列的rake任务.我宁愿将列重置为其默认值,但我找不到任何方法来帮助我完成此操作.reset_column_information不起作用

重置活动记录中单个列的最有效方法是什么?

activerecord ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.1

3
推荐指数
1
解决办法
2768
查看次数

设置多态关联

我正在尝试向我的网站添加"跟随"功能,但我找不到使用多态关联的正确方法.用户需要能够遵循3个不同的类,这3个类不会跟随用户.我在过去创建了一个跟随用户的用户,但事实证明这更加困难.

我的移民是

 class CreateRelationships < ActiveRecord::Migration
  def change
    create_table :relationships do |t|
      t.integer :follower_id
      t.integer :relations_id   
      t.string :relations_type    
      t.timestamps
    end
  end
 end
Run Code Online (Sandbox Code Playgroud)

我的关系模型是

class Relationship < ActiveRecord::Base
  attr_accessible :relations_id
  belongs_to :relations, :polymorphic => true
  has_many :followers, :class_name => "User"
end
Run Code Online (Sandbox Code Playgroud)

在我的用户模型中

has_many :relationships, :foreign_key => "supporter_id", :dependent => :destroy
Run Code Online (Sandbox Code Playgroud)

以及其他3个型号

has_many :relationships, :as => :relations
Run Code Online (Sandbox Code Playgroud)

我错过了设置这种关联的东西吗?

ruby ruby-on-rails ruby-on-rails-3

1
推荐指数
1
解决办法
1039
查看次数