相关疑难解决方法(0)

Rails:创建索引时"t.references"不起作用

class CreateBallots < ActiveRecord::Migration
  def change
    create_table :ballots do |t|
      t.references :user
      t.references :score
      t.references :election
      t.string :key
      t.timestamps
    end
    add_index :ballots, :user
    add_index :ballots, :score
    add_index :ballots, :election
  end
end
Run Code Online (Sandbox Code Playgroud)

结果是:

SQLite3::SQLException: table ballots has no column named user: CREATE  INDEX "index_ballots_on_user" ON "ballots" ("user")/home/muhd/awesomevote/db/migrate/20130624024349_create_ballots.rb:10:in `change'
Run Code Online (Sandbox Code Playgroud)

我以为t.references应该为我处理这件事?

ruby-on-rails rails-migrations ruby-on-rails-3.2

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

Rails的性能问题:如何发送gzip资产

我在生产环境中使用rails资产管道功能.我已经在nginx中编写了一些设置来发送gzip格式的文件,并且文件正在以gzip格式正常传输.我猜浏览器会自动解码它因此我无法找到js文件是否以gizp格式传入.

我已经放了以下命令,我在响应中得到"content-encoding:zip".

curl -v -H 'Accept-Encoding: gzip' -o /dev/null http://www.example.com/assets/style.css 2>&1 | grep -i Content-Encoding
Run Code Online (Sandbox Code Playgroud)

我在nginx中写了下面的设置来发送gzip格式的文件,文件正好以gzip格式出现.

location ~ ^/(assets)/  {
        root /home/webuser/app/woa/public;
        gzip_static on;
        expires max;
        add_header Cache-Control public;
        # access_log /dev/null;
        }
Run Code Online (Sandbox Code Playgroud)

我怎么才能知道文件是否以gzip格式出现?

另外,请建议任何其他有助于提高网站性能的选项.

performance gzip nginx ruby-on-rails-3 angularjs

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