我试图Heroku根据Heroku中2个应用程序之间的共享数据库在两个应用程序之间共享数据库,但在第二个应用程序上设置database_url会出错:
$ heroku config:add DATABASE_URL=postgres://...
Setting config vars and restarting pacific-headland-1960... failed
! Cannot destroy last attachment to billing app for resource loving-subtly-5807
Run Code Online (Sandbox Code Playgroud) 我有has_one和和belongs_to关联的两个模型。我想has_one根据相关对象是否存在对模型进行排序。
我目前可以例如根据关联的对象字段进行排序。
这是简化的代码:
class A < ActiveRecord::Base
belongs_to :B
end
class B < ActiveRecord::Base
has_one :B
end
q = A.all.search(params[:q])
as = q.result.includes(:b)
Run Code Online (Sandbox Code Playgroud)
我试过了:
sort_link @q, :b_id_present
sort_link @q, :b_present
sort_link @q, :b_id_null
sort_link @q, :b_null
Run Code Online (Sandbox Code Playgroud) 在常规的angularjs ui-router状态下,控制器每次激活状态时都会运行.我发现在离子应用程序中处理命名视图时并非如此.命名视图控制器每个元素(游戏)只运行一次.例如.用户显示游戏 - >控制器运行.然后用户进入另一个状态,并且当他们返回显示相同的游戏控制器时不再运行 - 该视图使用之前已经生成的范围.我想用控制器重新初始化游戏范围.
我的代码:
//app.js
.state('app.game', {
url: "/x/{gameID:int}",
views: {
'menuContent': {
templateUrl: "templates/html/my-game.html",
controller: 'GameCtrl'
}
}
})
Run Code Online (Sandbox Code Playgroud)
...
//controllers.js
controllers.controller('GameCtrl', function ($scope, $stateParams, Game) {
//alert("running controller");
Game.get({id: $stateParams.gameID}, function(res){
$scope.game = res;
});
})
Run Code Online (Sandbox Code Playgroud)
编辑:我实际上使用此代码进入游戏视图(目前正在玩Steven Wexler的guid想法)
<ion-view view-title="Games">
<ion-content>
<h1>Games</h1>
<ion-list>
<ion-item nav-clear menu-close href="#/app/x/{{game.id}}?guid= {{guid()}}" ng-repeat="game in games">
{{game.id}}
</ion-item>
</ion-list>
</ion-content>
</ion-view>
Run Code Online (Sandbox Code Playgroud) 所以我试过两个cordova插件:
https://github.com/knowledgecode/WebSocket-for-Android
和
https://github.com/mkuklis/phonegap-websocket
它应该使websockets在android上工作(我使用4.1 avd),但更新.当我创建一个websocket时,我收到错误:ReferenceError:未定义WebSocket
有任何想法吗?Websocket开箱即用,适用于Android 5
例:
map = %{a: 'apple', o: 'orange'}
Run Code Online (Sandbox Code Playgroud)
鉴于上面的地图,我想得到价值的关键'orange'.
这似乎是一个简单的问题,但我无法弄清楚:
我get_serving_url()在我的代码中调用函数并得到错误:
NameError:未定义全局名称"get_serving_url"
我的import语句目前看起来像是:来自google.appengine.api导入图片
之前我尝试了各种"从PIL导入图像"并导致导入错误.我最近安装了PIL库
我的python路径上有site-packages和PIL文件夹
我该如何get_serving_url()工作?
我有一个新的 Rails-Composeromniauth 应用程序。当使用 rspec 运行测试时,会出现以下错误:
$ rspec
/home/grzegorz/programing/integra/spec/support/helpers.rb:5:in `block in <top (required)>': uninitialized constant Omniauth (NameError)
from /home/grzegorz/.rvm/gems/ruby-2.2.2@integra/gems/rspec-core-3.3.1/lib/rspec/core.rb:97:in `configure'
from /home/grzegorz/programing/integra/spec/support/helpers.rb:4:in `<top (required)>'
from /home/grzegorz/programing/integra/spec/rails_helper.rb:23:in `block in <top (required)>'
from /home/grzegorz/programing/integra/spec/rails_helper.rb:23:in `each'
from /home/grzegorz/programing/integra/spec/rails_helper.rb:23:in `<top (required)>'
from /home/grzegorz/.rvm/gems/ruby-2.2.2@integra/gems/rspec-core-3.3.1/lib/rspec/core/configuration.rb:1280:in `require'
from /home/grzegorz/.rvm/gems/ruby-2.2.2@integra/gems/rspec-core-3.3.1/lib/rspec/core/configuration.rb:1280:in `block in requires='
from /home/grzegorz/.rvm/gems/ruby-2.2.2@integra/gems/rspec-core-3.3.1/lib/rspec/core/configuration.rb:1280:in `each'
from /home/grzegorz/.rvm/gems/ruby-2.2.2@integra/gems/rspec-core-3.3.1/lib/rspec/core/configuration.rb:1280:in `requires='
from /home/grzegorz/.rvm/gems/ruby-2.2.2@integra/gems/rspec-core-3.3.1/lib/rspec/core/configuration_options.rb:109:in `block in process_options_into'
from /home/grzegorz/.rvm/gems/ruby-2.2.2@integra/gems/rspec-core-3.3.1/lib/rspec/core/configuration_options.rb:108:in `each'
from /home/grzegorz/.rvm/gems/ruby-2.2.2@integra/gems/rspec-core-3.3.1/lib/rspec/core/configuration_options.rb:108:in `process_options_into'
from /home/grzegorz/.rvm/gems/ruby-2.2.2@integra/gems/rspec-core-3.3.1/lib/rspec/core/configuration_options.rb:21:in `configure'
from /home/grzegorz/.rvm/gems/ruby-2.2.2@integra/gems/rspec-core-3.3.1/lib/rspec/core/runner.rb:101:in `setup'
from /home/grzegorz/.rvm/gems/ruby-2.2.2@integra/gems/rspec-core-3.3.1/lib/rspec/core/runner.rb:88:in `run'
from /home/grzegorz/.rvm/gems/ruby-2.2.2@integra/gems/rspec-core-3.3.1/lib/rspec/core/runner.rb:73:in `run'
from /home/grzegorz/.rvm/gems/ruby-2.2.2@integra/gems/rspec-core-3.3.1/lib/rspec/core/runner.rb:41:in `invoke'
from /home/grzegorz/.rvm/gems/ruby-2.2.2@integra/gems/rspec-core-3.3.1/exe/rspec:4:in `<top (required)>' …Run Code Online (Sandbox Code Playgroud)