Rails 101 [練習作業7] 安裝 Rails Production Server 發生問題
我是 Rails 101 的讀者
閱讀 “[練習作業7] 將論壇 deploy 到租來的 VPS”
嘗試照著 http://github.com/jnstq/rails-nginx-passenger-ubuntu 安裝 Production Server
安裝完成之後
建立一個 Rails Application 在 Production Server
卻不能正確地執行,畫面出現 "We're sorry, but something went wrong." 訊息,畫面如下
如果我瀏覽該 Rails Application 的首頁,是可以看到首頁的,畫面如下。
我將 nginx 關閉之後,改用 WEBrick ,就可以正常執行 Rails Application,畫面如下。
我的 /opt/nginx/conf/nginx.conf 如下
http://dl.dropbox.com/u/77217614/Rails%20101%20Install%20Production%20Server%20Question/nginx.conf
我使用 Virtualbox 4.1.12 建制該 Production Server
Host OS 是 Mac OS X 10.7.3
Guest OS 是 Ubuntu 8.04 Server
http://releases.ubuntu.com/hardy/ubuntu-8.04.4-server-i386.iso
我將我的 Virtualbox Image 提供如下,讓歡迎測試。
http://dl.dropbox.com/u/77217614/Rails%20101%20Install%20Production%20Server%20Question/rails_server.ova
username: rubyonrailsserver
password: rubyonrailsserver
因為安裝過程有遇到一些訊息跟 http://github.com/jnstq/rails-nginx-passenger-ubuntu 不完全一樣,因此提供一下我安裝所使用的指令與步驟如下。
01
install ubuntu server
02
echo "alias ll='ls -l'" >> ~/.bash_aliases
03
edit .bashrc and uncomment the loading of .bash_aliases
04
sudo apt-get update
sudo apt-get upgrade
05
sudo dpkg-reconfigure tzdata
06
sudo apt-get install ntp
07
sudo ntpdate ntp.ubuntu.com # Update time
08
sudo hostname your-hostname
09
Add 127.0.0.1 your-hostname
sudo vim /etc/hosts
10
Write your-hostname in
sudo vim /etc/hostname
11
sudo apt-get install mysql-server libmysqlclient15-dev
12
Gemrc
Add the following lines to ~/.gemrc, this will speed up gem installation and prevent rdoc and ri from being generated, this is not nessesary in the production environment.
---
:sources:
- http://gems.rubyforge.org
- http://gems.github.com
gem: --no-ri --no-rdoc
13
sudo apt-get install build-essential zlib1g-dev libssl-dev libreadline5-dev
14
Download and install Ruby Enterprise Edition
wget http://rubyenterpriseedition.googlecode.com/files/ruby-enterprise-1.8.7-2012.02.tar.gz
tar xvfz ruby-enterprise-1.8.7-2012.02.tar.gz
rm ruby-enterprise-1.8.7-2012.02.tar.gz
cd ruby-enterprise-1.8.7-2012.02/
sudo ./installer
Change target folder to /opt/ruby for easier upgrade later on
15
Add Ruby Enterprise bin to PATH
echo "export PATH=/opt/ruby/bin:$PATH" >> ~/.profile && . ~/.profile
Verify the ruby installation
ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 20090928
16
sudo apt-get install git-core
17
sudo /opt/ruby/bin/passenger-install-nginx-module
18
cd
git clone git://github.com/jnstq/rails-nginx-passenger-ubuntu.git
19
sudo mv rails-nginx-passenger-ubuntu/nginx/nginx /etc/init.d/nginx
20
sudo chown root:root /etc/init.d/nginx
21
sudo /usr/sbin/update-rc.d -f nginx defaults
22
sudo apt-get remove imagemagick
23
sudo apt-get install libperl-dev gcc libjpeg62-dev libbz2-dev libtiff4-dev libwmf-dev libz-dev libpng12-dev libx11-dev libxt-dev libxext-dev libxml2-dev libfreetype6-dev liblcms1-dev libexif-dev perl libjasper-dev libltdl3-dev graphviz gs-gpl pkg-config
24
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
25
tar xvfz ImageMagick.tar.gz
26
cd ImageMagick-6.7.6-8
./configure
27
cd ImageMagick-6.7.6-8
make
28
cd ImageMagick-6.7.6-8
sudo make install
29
sudo ldconfig
30
sudo /opt/ruby/bin/ruby /opt/ruby/bin/gem install rmagick
31
sudo apt-get install vim-nox
32
rails new testapp -d mysql
33
cd testapp
input password
vim config/database.yml
34
insert gem 'therubyracer' into Gemfile
vim Gemfile
bundle
rake db:create:all
35
rails scaffold Post title:string body:text
36
rake db:migrate RAILS_ENV=production
謝謝版上的高手協助解決
感激不儘
Vincent
贴 log/production.log 出来看下?
Log 如下,謝謝。
Started GET "/assets/rails.png" for 192.168.1.5 at Thu May 03 12:34:45 +0800 2012
Served asset /rails.png - 200 OK (14ms)
Started GET "/posts" for 192.168.1.5 at Thu May 03 12:34:50 +0800 2012
Processing by PostsController#index as HTML
Mysql2::Error: Table 'testapp_development.posts' doesn't exist: SHOW FULL FIELDS FROM posts
Completed 500 Internal Server Error in 39ms
ActiveRecord::StatementInvalid (Mysql2::Error: Table 'testapp_development.posts' doesn't exist: SHOW FULL FIELDS FROM posts
):
app/controllers/posts_controller.rb:5:in `index'
Rendered /opt/ruby/lib/ruby/gems/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.8ms)
Rendered /opt/ruby/lib/ruby/gems/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.6ms)
Rendered /opt/ruby/lib/ruby/gems/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (7.1ms)
[1m[36m (57.3ms)[0m [1mCREATE TABLE schema_migrations
(version
varchar(255) NOT NULL) ENGINE=InnoDB[0m
[1m[35m (2.8ms)[0m CREATE UNIQUE INDEX unique_schema_migrations
ON schema_migrations
(version
)
[1m[36m (0.1ms)[0m [1mSELECT schema_migrations
.version
FROM schema_migrations
[0m
Migrating to CreatePosts (20120503030200)
[1m[35m (1.0ms)[0m CREATE TABLE posts
(id
int(11) DEFAULT NULL auto_increment PRIMARY KEY, title
varchar(255), body
text, created_at
datetime NOT NULL, updated_at
datetime NOT NULL) ENGINE=InnoDB
[1m[36m (0.9ms)[0m [1mINSERT INTO schema_migrations
(version
) VALUES ('20120503030200')[0m
[1m[35m (0.1ms)[0m SELECT schema_migrations
.version
FROM schema_migrations
Started GET "/posts" for 192.168.1.5 at Thu May 03 12:36:26 +0800 2012
Processing by PostsController#index as HTML
[1m[36mPost Load (0.1ms)[0m [1mSELECT posts
.* FROM posts
[0m
Rendered posts/index.html.erb within layouts/application (31.3ms)
Compiled posts.css (39ms) (pid 5032)
Compiled scaffolds.css (15ms) (pid 5032)
Compiled application.css (73ms) (pid 5032)
Compiled jquery.js (4ms) (pid 5032)
Compiled jquery_ujs.js (0ms) (pid 5032)
Compiled posts.js (88ms) (pid 5032)
Compiled application.js (158ms) (pid 5032)
Completed 200 OK in 299ms (Views: 287.1ms | ActiveRecord: 1.0ms)
Started GET "/assets/scaffolds.css?body=1" for 192.168.1.5 at Thu May 03 12:36:27 +0800 2012
Served asset /scaffolds.css - 200 OK (2ms)
Started GET "/assets/posts.css?body=1" for 192.168.1.5 at Thu May 03 12:36:27 +0800 2012
Served asset /posts.css - 200 OK (2ms)
Started GET "/assets/application.css?body=1" for 192.168.1.5 at Thu May 03 12:36:27 +0800 2012
Served asset /application.css - 200 OK (3ms)
Started GET "/assets/jquery.js?body=1" for 192.168.1.5 at Thu May 03 12:36:27 +0800 2012
Served asset /jquery.js - 200 OK (5ms)
Started GET "/assets/jquery_ujs.js?body=1" for 192.168.1.5 at Thu May 03 12:36:27 +0800 2012
Served asset /jquery_ujs.js - 200 OK (3ms)
Started GET "/assets/posts.js?body=1" for 192.168.1.5 at Thu May 03 12:36:27 +0800 2012
Served asset /posts.js - 200 OK (3ms)
Started GET "/assets/application.js?body=1" for 192.168.1.5 at Thu May 03 12:36:27 +0800 2012
Served asset /application.js - 200 OK (7ms)
Started GET "/posts/new" for 192.168.1.5 at Thu May 03 12:36:29 +0800 2012
Processing by PostsController#new as HTML
Rendered posts/_form.html.erb (17.5ms)
Rendered posts/new.html.erb within layouts/application (21.2ms)
Completed 200 OK in 88ms (Views: 85.0ms | ActiveRecord: 0.0ms)
Started GET "/assets/jquery.js?body=1" for 192.168.1.5 at Thu May 03 12:36:34 +0800 2012
Served asset /jquery.js - 304 Not Modified (0ms)
Started POST "/posts" for 192.168.1.5 at Thu May 03 12:36:39 +0800 2012
Processing by PostsController#create as HTML
Parameters: {"commit"=>"Create Post", "utf8"=>"✓", "authenticity_token"=>"yL/VE2Bfsd8aHDL+9hu6LzA44MqDCjgCcZwYQTZ5wcc=", "post"=>{"body"=>"dfasdfasf", "title"=>"aaa"}}
[1m[35m (0.1ms)[0m BEGIN
[1m[36mSQL (0.2ms)[0m [1mINSERT INTO posts
(body
, created_at
, title
, updated_at
) VALUES ('dfasdfasf', '2012-05-03 04:36:39', 'aaa', '2012-05-03 04:36:39')[0m
[1m[35m (0.5ms)[0m COMMIT
Redirected to http://192.168.1.11:3000/posts/1
Completed 302 Found in 8ms (ActiveRecord: 0.8ms)
Started GET "/posts/1" for 192.168.1.5 at Thu May 03 12:36:39 +0800 2012
Processing by PostsController#show as HTML
Parameters: {"id"=>"1"}
[1m[36mPost Load (0.3ms)[0m [1mSELECT posts
.* FROM posts
WHERE posts
.id
= 1 LIMIT 1[0m
Rendered posts/show.html.erb within layouts/application (0.9ms)
Completed 200 OK in 28ms (Views: 24.9ms | ActiveRecord: 0.3ms)
Started GET "/assets/jquery.js?body=1" for 192.168.1.5 at Thu May 03 12:36:39 +0800 2012
Served asset /jquery.js - 304 Not Modified (0ms)
Started GET "/posts/1/edit" for 192.168.1.5 at Thu May 03 12:36:42 +0800 2012
Processing by PostsController#edit as HTML
Parameters: {"id"=>"1"}
[1m[35mPost Load (0.1ms)[0m SELECT posts
.* FROM posts
WHERE posts
.id
= 1 LIMIT 1
Rendered posts/_form.html.erb (1.8ms)
Rendered posts/edit.html.erb within layouts/application (2.9ms)
Completed 200 OK in 22ms (Views: 20.5ms | ActiveRecord: 0.1ms)
Started GET "/assets/jquery.js?body=1" for 192.168.1.5 at Thu May 03 12:36:42 +0800 2012
Served asset /jquery.js - 304 Not Modified (0ms)
Started PUT "/posts/1" for 192.168.1.5 at Thu May 03 12:36:47 +0800 2012
Processing by PostsController#update as HTML
Parameters: {"commit"=>"Update Post", "utf8"=>"✓", "authenticity_token"=>"yL/VE2Bfsd8aHDL+9hu6LzA44MqDCjgCcZwYQTZ5wcc=", "post"=>{"body"=>"hfgghsdfgds", "title"=>"qqqq"}, "id"=>"1"}
[1m[36mPost Load (0.1ms)[0m [1mSELECT posts
.* FROM posts
WHERE posts
.id
= 1 LIMIT 1[0m
[1m[35m (0.1ms)[0m BEGIN
[1m[36m (0.3ms)[0m [1mUPDATE posts
SET title
= 'qqqq', updated_at
= '2012-05-03 04:36:47', body
= 'hfgghsdfgds' WHERE posts
.id
= 1[0m
[1m[35m (0.6ms)[0m COMMIT
Redirected to http://192.168.1.11:3000/posts/1
Completed 302 Found in 4ms (ActiveRecord: 1.0ms)
Started GET "/posts/1" for 192.168.1.5 at Thu May 03 12:36:47 +0800 2012
Processing by PostsController#show as HTML
Parameters: {"id"=>"1"}
[1m[36mPost Load (0.2ms)[0m [1mSELECT posts
.* FROM posts
WHERE posts
.id
= 1 LIMIT 1[0m
Rendered posts/show.html.erb within layouts/application (0.5ms)
Completed 200 OK in 5ms (Views: 3.9ms | ActiveRecord: 0.2ms)
Started GET "/assets/jquery.js?body=1" for 192.168.1.5 at Thu May 03 12:36:47 +0800 2012
Served asset /jquery.js - 304 Not Modified (0ms)
Started GET "/posts" for 192.168.1.5 at Thu May 03 12:36:48 +0800 2012
Processing by PostsController#index as HTML
[1m[35mPost Load (0.2ms)[0m SELECT posts
.* FROM posts
Rendered posts/index.html.erb within layouts/application (1.0ms)
Completed 200 OK in 5ms (Views: 3.8ms | ActiveRecord: 0.2ms)
Started GET "/assets/jquery.js?body=1" for 192.168.1.5 at Thu May 03 12:36:48 +0800 2012
Served asset /jquery.js - 304 Not Modified (0ms)
Started DELETE "/posts/1" for 192.168.1.5 at Thu May 03 12:36:52 +0800 2012
Processing by PostsController#destroy as HTML
Parameters: {"authenticity_token"=>"yL/VE2Bfsd8aHDL+9hu6LzA44MqDCjgCcZwYQTZ5wcc=", "id"=>"1"}
[1m[36mPost Load (0.1ms)[0m [1mSELECT posts
.* FROM posts
WHERE posts
.id
= 1 LIMIT 1[0m
[1m[35m (0.1ms)[0m BEGIN
[1m[36mSQL (0.3ms)[0m [1mDELETE FROM posts
WHERE posts
.id
= 1[0m
[1m[35m (9.2ms)[0m COMMIT
Redirected to http://192.168.1.11:3000/posts
Completed 302 Found in 13ms (ActiveRecord: 9.7ms)
Started GET "/posts" for 192.168.1.5 at Thu May 03 12:36:52 +0800 2012
Processing by PostsController#index as HTML
[1m[36mPost Load (0.6ms)[0m [1mSELECT posts
.* FROM posts
[0m
Rendered posts/index.html.erb within layouts/application (0.5ms)
Completed 200 OK in 7ms (Views: 5.6ms | ActiveRecord: 0.6ms)
Started GET "/assets/jquery.js?body=1" for 192.168.1.5 at Thu May 03 12:36:52 +0800 2012
Served asset /jquery.js - 304 Not Modified (0ms)
Started GET "/assets/rails.png" for 192.168.1.5 at Thu May 03 12:42:14 +0800 2012
Served asset /rails.png - 304 Not Modified (1ms)
Started GET "/rails/info/properties" for 192.168.1.5 at Thu May 03 12:42:16 +0800 2012
[1m[36m (0.0ms)[0m [1mSELECT schema_migrations
.version
FROM schema_migrations
[0m
Processing by Rails::InfoController#properties as /
Rendered inline template (0.9ms)
Completed 200 OK in 5ms (Views: 4.5ms | ActiveRecord: 0.0ms)
Started GET "/rails/info/properties" for 192.168.1.5 at Thu May 03 12:42:20 +0800 2012
Processing by Rails::InfoController#properties as /
Rendered inline template (0.3ms)
Completed 200 OK in 1ms (Views: 0.8ms | ActiveRecord: 0.0ms)
Started GET "/rails/info/properties" for 192.168.1.5 at Thu May 03 12:42:21 +0800 2012
Processing by Rails::InfoController#properties as /
Rendered inline template (0.2ms)
Completed 200 OK in 1ms (Views: 0.5ms | ActiveRecord: 0.0ms)
Started GET "/posts" for 192.168.1.5 at Thu May 03 12:42:26 +0800 2012
Processing by PostsController#index as HTML
[1m[35mPost Load (0.1ms)[0m SELECT posts
.* FROM posts
Rendered posts/index.html.erb within layouts/application (0.7ms)
Completed 200 OK in 28ms (Views: 14.6ms | ActiveRecord: 0.8ms)
Started GET "/assets/posts.css?body=1" for 192.168.1.5 at Thu May 03 12:42:26 +0800 2012
Served asset /posts.css - 304 Not Modified (1ms)
Started GET "/assets/application.css?body=1" for 192.168.1.5 at Thu May 03 12:42:26 +0800 2012
Served asset /application.css - 304 Not Modified (3ms)
Started GET "/assets/jquery_ujs.js?body=1" for 192.168.1.5 at Thu May 03 12:42:26 +0800 2012
Served asset /jquery_ujs.js - 304 Not Modified (2ms)
Started GET "/assets/jquery.js?body=1" for 192.168.1.5 at Thu May 03 12:42:26 +0800 2012
Served asset /jquery.js - 304 Not Modified (3ms)
Started GET "/assets/scaffolds.css?body=1" for 192.168.1.5 at Thu May 03 12:42:26 +0800 2012
Served asset /scaffolds.css - 304 Not Modified (2ms)
Started GET "/assets/posts.js?body=1" for 192.168.1.5 at Thu May 03 12:42:26 +0800 2012
Served asset /posts.js - 304 Not Modified (1ms)
Started GET "/assets/application.js?body=1" for 192.168.1.5 at Thu May 03 12:42:26 +0800 2012
Served asset /application.js - 304 Not Modified (7ms)
Started GET "/assets/rails.png" for 192.168.1.5 at Thu May 03 13:08:06 +0800 2012
Served asset /rails.png - 304 Not Modified (1ms)
Started GET "/posts" for 192.168.1.5 at Thu May 03 13:08:11 +0800 2012
Processing by PostsController#index as HTML
[1m[36mPost Load (0.1ms)[0m [1mSELECT posts
.* FROM posts
[0m
Rendered posts/index.html.erb within layouts/application (1.5ms)
Completed 200 OK in 68ms (Views: 18.0ms | ActiveRecord: 0.8ms)
Started GET "/assets/jquery_ujs.js?body=1" for 192.168.1.5 at Thu May 03 13:08:11 +0800 2012
Served asset /jquery_ujs.js - 304 Not Modified (2ms)
Started GET "/assets/jquery.js?body=1" for 192.168.1.5 at Thu May 03 13:08:11 +0800 2012
Served asset /jquery.js - 304 Not Modified (8ms)
Started GET "/assets/scaffolds.css?body=1" for 192.168.1.5 at Thu May 03 13:08:11 +0800 2012
Served asset /scaffolds.css - 304 Not Modified (2ms)
Started GET "/assets/posts.css?body=1" for 192.168.1.5 at Thu May 03 13:08:11 +0800 2012
Served asset /posts.css - 304 Not Modified (2ms)
Started GET "/assets/application.css?body=1" for 192.168.1.5 at Thu May 03 13:08:11 +0800 2012
Served asset /application.css - 304 Not Modified (4ms)
Started GET "/assets/posts.js?body=1" for 192.168.1.5 at Thu May 03 13:08:11 +0800 2012
Served asset /posts.js - 304 Not Modified (1ms)
Started GET "/assets/application.js?body=1" for 192.168.1.5 at Thu May 03 13:08:11 +0800 2012
Served asset /application.js - 304 Not Modified (7ms)
Started GET "/posts/new" for 192.168.1.5 at Thu May 03 13:08:12 +0800 2012
Processing by PostsController#new as HTML
Rendered posts/_form.html.erb (4.0ms)
Rendered posts/new.html.erb within layouts/application (6.3ms)
Completed 200 OK in 13ms (Views: 9.8ms | ActiveRecord: 0.0ms)
Started GET "/assets/application.css?body=1" for 192.168.1.5 at Thu May 03 13:08:12 +0800 2012
Served asset /application.css - 304 Not Modified (0ms)
Started GET "/assets/scaffolds.css?body=1" for 192.168.1.5 at Thu May 03 13:08:12 +0800 2012
Served asset /scaffolds.css - 304 Not Modified (0ms)
Started GET "/assets/posts.css?body=1" for 192.168.1.5 at Thu May 03 13:08:17 +0800 2012
Served asset /posts.css - 304 Not Modified (0ms)
Started GET "/assets/posts.js?body=1" for 192.168.1.5 at Thu May 03 13:08:17 +0800 2012
Served asset /posts.js - 304 Not Modified (0ms)
Started GET "/assets/jquery_ujs.js?body=1" for 192.168.1.5 at Thu May 03 13:08:18 +0800 2012
Served asset /jquery_ujs.js - 304 Not Modified (0ms)
Started GET "/assets/jquery.js?body=1" for 192.168.1.5 at Thu May 03 13:08:18 +0800 2012
Served asset /jquery.js - 304 Not Modified (0ms)
Started GET "/assets/application.js?body=1" for 192.168.1.5 at Thu May 03 13:08:18 +0800 2012
Served asset /application.js - 304 Not Modified (0ms)
Started POST "/posts" for 192.168.1.5 at Thu May 03 13:08:21 +0800 2012
Processing by PostsController#create as HTML
Parameters: {"post"=>{"body"=>"asdfasf", "title"=>"asdfas"}, "authenticity_token"=>"yL/VE2Bfsd8aHDL+9hu6LzA44MqDCjgCcZwYQTZ5wcc=", "utf8"=>"✓", "commit"=>"Create Post"}
[1m[35m (0.1ms)[0m BEGIN
[1m[36mSQL (0.2ms)[0m [1mINSERT INTO posts
(body
, created_at
, title
, updated_at
) VALUES ('asdfasf', '2012-05-03 05:08:21', 'asdfas', '2012-05-03 05:08:21')[0m
[1m[35m (71.1ms)[0m COMMIT
Redirected to http://192.168.1.11:3000/posts/2
Completed 302 Found in 77ms (ActiveRecord: 71.5ms)
Started GET "/posts/2" for 192.168.1.5 at Thu May 03 13:08:21 +0800 2012
Processing by PostsController#show as HTML
Parameters: {"id"=>"2"}
[1m[36mPost Load (0.2ms)[0m [1mSELECT posts
.* FROM posts
WHERE posts
.id
= 2 LIMIT 1[0m
Rendered posts/show.html.erb within layouts/application (0.8ms)
Completed 200 OK in 8ms (Views: 5.3ms | ActiveRecord: 0.2ms)
Started GET "/assets/posts.css?body=1" for 192.168.1.5 at Thu May 03 13:08:21 +0800 2012
Served asset /posts.css - 304 Not Modified (0ms)
Started GET "/assets/jquery.js?body=1" for 192.168.1.5 at Thu May 03 13:08:21 +0800 2012
Served asset /jquery.js - 304 Not Modified (0ms)
Started GET "/assets/scaffolds.css?body=1" for 192.168.1.5 at Thu May 03 13:08:21 +0800 2012
Served asset /scaffolds.css - 304 Not Modified (0ms)
Started GET "/assets/application.css?body=1" for 192.168.1.5 at Thu May 03 13:08:21 +0800 2012
Served asset /application.css - 304 Not Modified (0ms)
Started GET "/assets/jquery_ujs.js?body=1" for 192.168.1.5 at Thu May 03 13:08:21 +0800 2012
Served asset /jquery_ujs.js - 304 Not Modified (0ms)
Started GET "/assets/posts.js?body=1" for 192.168.1.5 at Thu May 03 13:08:21 +0800 2012
Served asset /posts.js - 304 Not Modified (0ms)
Started GET "/assets/application.js?body=1" for 192.168.1.5 at Thu May 03 13:08:21 +0800 2012
Served asset /application.js - 304 Not Modified (0ms)
Started GET "/posts" for 192.168.1.5 at Thu May 03 13:08:23 +0800 2012
Processing by PostsController#index as HTML
[1m[35mPost Load (0.2ms)[0m SELECT posts
.* FROM posts
Rendered posts/index.html.erb within layouts/application (1.1ms)
Completed 200 OK in 6ms (Views: 4.8ms | ActiveRecord: 0.2ms)
Started GET "/assets/posts.css?body=1" for 192.168.1.5 at Thu May 03 13:08:23 +0800 2012
Served asset /posts.css - 304 Not Modified (0ms)
Started GET "/assets/posts.js?body=1" for 192.168.1.5 at Thu May 03 13:08:23 +0800 2012
Served asset /posts.js - 304 Not Modified (0ms)
Started GET "/assets/jquery_ujs.js?body=1" for 192.168.1.5 at Thu May 03 13:08:23 +0800 2012
Served asset /jquery_ujs.js - 304 Not Modified (0ms)
Started GET "/assets/application.css?body=1" for 192.168.1.5 at Thu May 03 13:08:23 +0800 2012
Served asset /application.css - 304 Not Modified (0ms)
Started GET "/assets/scaffolds.css?body=1" for 192.168.1.5 at Thu May 03 13:08:23 +0800 2012
Served asset /scaffolds.css - 304 Not Modified (0ms)
Started GET "/assets/jquery.js?body=1" for 192.168.1.5 at Thu May 03 13:08:23 +0800 2012
Served asset /jquery.js - 304 Not Modified (0ms)
Started GET "/assets/application.js?body=1" for 192.168.1.5 at Thu May 03 13:08:23 +0800 2012
Served asset /application.js - 304 Not Modified (0ms)
Started GET "/posts" for 192.168.1.5 at Thu May 03 13:52:51 +0800 2012
Processing by PostsController#index as HTML
[1m[36mPost Load (0.2ms)[0m [1mSELECT posts
.* FROM posts
[0m
Rendered posts/index.html.erb within layouts/application (2.8ms)
Completed 200 OK in 374ms (Views: 321.8ms | ActiveRecord: 1.3ms)
Started GET "/assets/posts.js?body=1" for 192.168.1.5 at Thu May 03 13:52:53 +0800 2012
Served asset /posts.js - 304 Not Modified (2ms)
Started GET "/assets/posts.css?body=1" for 192.168.1.5 at Thu May 03 13:52:53 +0800 2012
Served asset /posts.css - 304 Not Modified (1ms)
Started GET "/assets/application.css?body=1" for 192.168.1.5 at Thu May 03 13:52:53 +0800 2012
Served asset /application.css - 304 Not Modified (4ms)
Started GET "/assets/jquery_ujs.js?body=1" for 192.168.1.5 at Thu May 03 13:52:53 +0800 2012
Served asset /jquery_ujs.js - 304 Not Modified (2ms)
Started GET "/assets/jquery.js?body=1" for 192.168.1.5 at Thu May 03 13:52:53 +0800 2012
Served asset /jquery.js - 304 Not Modified (4ms)
Started GET "/assets/scaffolds.css?body=1" for 192.168.1.5 at Thu May 03 13:52:53 +0800 2012
Served asset /scaffolds.css - 304 Not Modified (1ms)
Started GET "/assets/rails.png" for 192.168.1.5 at Thu May 03 13:52:54 +0800 2012
Served asset /rails.png - 304 Not Modified (16ms)
Started GET "/rails/info/properties" for 192.168.1.5 at Thu May 03 13:52:57 +0800 2012
[1m[35m (0.2ms)[0m SELECT schema_migrations
.version
FROM schema_migrations
Processing by Rails::InfoController#properties as /
Rendered inline template (0.2ms)
Completed 200 OK in 1ms (Views: 0.8ms | ActiveRecord: 0.0ms)
Started GET "/rails/info/properties" for 192.168.1.5 at Thu May 03 13:53:06 +0800 2012
Processing by Rails::InfoController#properties as /
Rendered inline template (0.2ms)
Completed 200 OK in 1ms (Views: 0.5ms | ActiveRecord: 0.0ms)
Started GET "/rails/info/properties" for 192.168.1.5 at Thu May 03 13:53:09 +0800 2012
Processing by Rails::InfoController#properties as /
Rendered inline template (0.3ms)
Completed 200 OK in 2ms (Views: 0.9ms | ActiveRecord: 0.0ms)
Started GET "/assets/rails.png" for 192.168.1.5 at Thu May 03 13:53:11 +0800 2012
Served asset /rails.png - 304 Not Modified (0ms)
Started GET "/posts" for 192.168.1.5 at Thu May 03 13:53:45 +0800 2012
Processing by PostsController#index as HTML
[1m[36mPost Load (0.1ms)[0m [1mSELECT posts
.* FROM posts
[0m
Rendered posts/index.html.erb within layouts/application (1.6ms)
Completed 200 OK in 7ms (Views: 5.5ms | ActiveRecord: 0.1ms)
Started GET "/posts" for 192.168.1.5 at Thu May 03 13:53:45 +0800 2012
Processing by PostsController#index as HTML
[1m[35mPost Load (0.1ms)[0m SELECT posts
.* FROM posts
Rendered posts/index.html.erb within layouts/application (1.4ms)
Completed 200 OK in 8ms (Views: 6.9ms | ActiveRecord: 0.1ms)
Started GET "/assets/posts.css?body=1" for 192.168.1.5 at Thu May 03 13:53:45 +0800 2012
Served asset /posts.css - 200 OK (0ms)
Started GET "/assets/application.css?body=1" for 192.168.1.5 at Thu May 03 13:53:45 +0800 2012
Served asset /application.css - 200 OK (0ms)
Started GET "/assets/jquery_ujs.js?body=1" for 192.168.1.5 at Thu May 03 13:53:45 +0800 2012
Served asset /jquery_ujs.js - 200 OK (0ms)
Started GET "/assets/jquery.js?body=1" for 192.168.1.5 at Thu May 03 13:53:45 +0800 2012
Served asset /jquery.js - 200 OK (0ms)
Started GET "/assets/scaffolds.css?body=1" for 192.168.1.5 at Thu May 03 13:53:45 +0800 2012
Served asset /scaffolds.css - 200 OK (0ms)
Started GET "/assets/posts.js?body=1" for 192.168.1.5 at Thu May 03 13:53:45 +0800 2012
Served asset /posts.js - 200 OK (0ms)
Started GET "/assets/application.js?body=1" for 192.168.1.5 at Thu May 03 13:53:45 +0800 2012
Served asset /application.js - 200 OK (54ms)
已經解決了將 config.assets.compile 設為 true
感謝回應
# config/environments/production.rb
...
config.assets.compile = true
...
You will get better performance in production if you set config.assets.compile to false in production.rb and precompile your assets. You can precompile with this rake task:
bundle exec rake assets:precompile
If you are using Capistrano, version 2.8.0 has a recipe to handle this at deploy time. For more info, see the "In Production" section of the Asset Pipeline Guide: http://guides.rubyonrails.org/asset_pipeline.html