我一直在我的服务器上收到此错误: [error] Could not check origin for Phoenix.Socket transport.
我有一个在heroku上运行的Phoenix和JS应用程序,在使用频道的myapp.herokuapp.com上很好.
我遵循heroku自定义域指令,并且在将我的prod.exs配置更改为:url: [scheme: "https", host: "myapp.com", port: 443]
from 后,无法加载我的应用程序的javascript :
url: [scheme: "https", host: "myapp.herokuapp.com", port: 443]
使用自定义域myapp.com访问应用程序时出现此JS错误:
WebSocket connection to 'wss://myapp.com/socket/websocket?token=undefined&vsn=1.0.0' failed: Error during WebSocket handshake: Unexpected response code: 400
Run Code Online (Sandbox Code Playgroud)
伴随着heroku日志:
2016-11-27T03:27:52.259269+00:00 heroku[router]: at=info method=GET path="/socket/websocket?token=undefined&vsn=1.0.0" host=myapp.com request_id=94bd304b-e8f5-44aa-aff0-9336425e40b3 fwd="2601:602:9301:2b00:3c91:6660:9593:ad2c,2601:0602:9301:2b00:3c91:6660:9593:ad2c,108.162.245.66" dyno=web.1 connect=1ms service=1ms status=400 bytes=119
2016-11-27T03:28:03.671267+00:00 heroku[router]: at=info method=GET path="/socket/websocket?token=undefined&vsn=1.0.0" host=myapp.herokuapp.com request_id=71483e0c-8f2a-4485-8506-5931513de1fb fwd="50.159.116.207" dyno=web.1 connect=0ms service=1ms status=403 bytes=195
2016-11-27T03:28:03.650158+00:00 app[web.1]: 03:28:03.649 [error] Could not check origin for …Run Code Online (Sandbox Code Playgroud) 在信誉系统gem的RailsCast之后,我将以下代码添加到microposts_controller中
def index
@microposts = Micropost.paginate(page: params[:page]).find_with_reputation(:votes, :all, order: "votes desc")
@micropost = current_user.microposts.build
end
Run Code Online (Sandbox Code Playgroud)
但是除了我在模型中设置的默认范围之外,我的索引操作中没有排序
在我的微博模型中,我有
class Micropost < ActiveRecord::Base
belongs_to :user
has_many :retweets
has_reputation :votes, source: :user, aggregated_by: :sum
default_scope -> { order('created_at DESC') }
Run Code Online (Sandbox Code Playgroud)
如果我将默认范围更改为
default_scope -> { order('votes DESC') }
Run Code Online (Sandbox Code Playgroud)
它的工作方式只是我想要的索引页面,但打破了我的所有其他页面.
我尝试删除默认范围并留在find_with_reputation方法中,但它仍然没有按投票排序.
我也尝试在像这样的微博模型中的方法中定义范围
def self.popular
find_with_reputation(:votes, :all, {:order => 'votes desc'})
end
Run Code Online (Sandbox Code Playgroud)
并像这样在microposts_controller中创建代码
def index
@microposts = Micropost.paginate(page: params[:page]).popular
@micropost = current_user.microposts.build
end
Run Code Online (Sandbox Code Playgroud)
它仍然没有按投票排序.
这是访问微博索引页面的日志输出的副本 https://gist.github.com/anonymous/9745552
这是宝石的链接https://github.com/NARKOZ/activerecord-reputation-system/tree/rails4
我的routes.rb用于微博看起来像这样
resources :microposts, only: [:create, :destroy, :index] do …Run Code Online (Sandbox Code Playgroud) sorting activerecord ruby-on-rails railscasts ruby-on-rails-4
我正在使用TeamTreehouse.com(设置)推荐的虚拟盒设置(vagrant和virtualbox),每次我尝试启动新项目或安装新gem时,都会出现以下错误:
Errno::ENOSPC: No space left on device - /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/execjs-2.2.1
要么
Errno::ENOSPC: No space left on device - /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/cache/rails_serve_static_assets-0.0.2.gem
Run Code Online (Sandbox Code Playgroud)
或者当我进入虚拟框时我会得到
/home/treehouse/.rbenv/libexec/rbenv-init: line 151: cannot create temp file for here-document: No space left on
device
Run Code Online (Sandbox Code Playgroud)
我现在有几个项目,我想我在某个地方消耗了太多空间,但我不知道虚拟盒子的工作原理.它运行Ubuntu 12.04.3 LTS(GNU/Linux 3.8.0-41-generic i686).这是我的df -h日志
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/treehouse--vg-root 7.0G 4.8G 2.0G 72% /
udev 240M 4.0K 240M 1% /dev
tmpfs 50M 292K 50M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 248M 0 248M 0% /run/shm …Run Code Online (Sandbox Code Playgroud) activerecord ×1
cloudflare ×1
elixir ×1
heroku ×1
javascript ×1
railscasts ×1
rbenv ×1
sorting ×1
vagrant ×1
virtualbox ×1