更新:顯然,我的資產管道存在一些問題;我的資產沒有被預編譯,導致500錯誤。我已經發布了一些關於如何在下面解決它的細節。Apache與Rails應用程序搭配使用的應用程序
我知道有關於這個StackOverflow上和其他幾個問題,但我一直在努力,現在這個問題一天左右,因此到目前爲止,我還沒有能夠找到一個解決方案。
這裏是我的問題:我的Rails應用程序不斷拋出我一個錯誤500(「很抱歉,但出事了。」)我爲了嘗試和主機安裝RVM,Apache和乘客在我的服務器一個rails應用程序(全部安裝爲sudo)。我已經成功地遵循了phusion主頁上的安裝說明,但是當它將其鏈接到我的Rails應用程序時,我遇到了很多問題。
下面是一些相關信息的問題:
我的應用程序的根目錄是/ SRV/myappname
我development.log文件顯示以下的輸出:
Started GET "/messages" for 127.0.0.1 at 2013-07-16 15:05:15 -0400 Processing by MessagesController#index as HTML User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]] Message Load (0.0ms) SELECT "messages".* FROM "messages" WHERE "messages"."to_user_id" = 2 User Load (1.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 1]] (0.0ms) SELECT COUNT(*) FROM "messages" WHERE "messages"."to_user_id" = 2 Rendered messages/index.html.erb within layouts/application (3.0ms) Completed 500 Internal Server Error in 24ms RuntimeError - 2: app/views/messages/index.html.erb:17:in `block in _app_views_messages_index_html_erb__568106274_50485404' app/views/messages/index.html.erb:16:in `_app_views_messages_index_html_erb__568106274_50485404' actionpack (3.2.8) lib/action_view/template.rb:145:in `block in render' activesupport (3.2.8) lib/active_support/notifications.rb:125:in `instrument' actionpack (3.2.8) lib/action_view/template.rb:143:in `render' actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:47:in `block (2 levels) in render_template' actionpack (3.2.8) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument' activesupport (3.2.8) lib/active_support/notifications.rb:123:in `block in instrument' activesupport (3.2.8) lib/active_support/notifications/instrumenter.rb:20:in `instrument' activesupport (3.2.8) lib/active_support/notifications.rb:123:in `instrument' actionpack (3.2.8) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument' actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:46:in `block in render_template' actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:54:in `render_with_layout' actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:45:in `render_template' actionpack (3.2.8) lib/action_view/renderer/template_renderer.rb:18:in `render' actionpack (3.2.8) lib/action_view/renderer/renderer.rb:36:in `render_template' actionpack (3.2.8) lib/action_view/renderer/renderer.rb:17:in `render' actionpack (3.2.8) lib/abstract_controller/rendering.rb:110:in `_render_template' actionpack (3.2.8) lib/action_controller/metal/streaming.rb:225:in `_render_template' actionpack (3.2.8) lib/abstract_controller/rendering.rb:103:in `render_to_body' actionpack (3.2.8) lib/action_controller/metal/renderers.rb:28:in `render_to_body' actionpack (3.2.8) lib/action_controller/metal/compatibility.rb:50:in `render_to_body' actionpack (3.2.8) lib/abstract_controller/rendering.rb:88:in `render' actionpack (3.2.8) lib/action_controller/metal/rendering.rb:16:in `render' actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render' activesupport (3.2.8) lib/active_support/core_ext/benchmark.rb:5:in `block in ms' C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/benchmark.rb:295:in `realtime' activesupport (3.2.8) lib/active_support/core_ext/benchmark.rb:5:in `ms' actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:40:in `block in render' actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime' activerecord (3.2.8) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime' actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:39:in `render' actionpack (3.2.8) lib/action_controller/metal/implicit_render.rb:10:in `default_render' actionpack (3.2.8) lib/action_controller/metal/mime_responds.rb:196:in `respond_to' app/controllers/messages_controller.rb:21:in `index' actionpack (3.2.8) lib/action_controller/metal/implicit_render.rb:4:in `send_action' actionpack (3.2.8) lib/abstract_controller/base.rb:167:in `process_action' actionpack (3.2.8) lib/action_controller/metal/rendering.rb:10:in `process_action' actionpack (3.2.8) lib/abstract_controller/callbacks.rb:18:in `block in process_action' activesupport (3.2.8) lib/active_support/callbacks.rb:425:in `_run__105841733__process_action__861948368__callbacks' activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback' activesupport (3.2.8) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks' activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks' actionpack (3.2.8) lib/abstract_controller/callbacks.rb:17:in `process_action' actionpack (3.2.8) lib/action_controller/metal/rescue.rb:29:in `process_action' actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action' activesupport (3.2.8) lib/active_support/notifications.rb:123:in `block in instrument' activesupport (3.2.8) lib/active_support/notifications/instrumenter.rb:20:in `instrument' activesupport (3.2.8) lib/active_support/notifications.rb:123:in `instrument' actionpack (3.2.8) lib/action_controller/metal/instrumentation.rb:29:in `process_action' actionpack (3.2.8) lib/action_controller/metal/params_wrapper.rb:207:in `process_action' activerecord (3.2.8) lib/active_record/railties/controller_runtime.rb:18:in `process_action' actionpack (3.2.8) lib/abstract_controller/base.rb:121:in `process' actionpack (3.2.8) lib/abstract_controller/rendering.rb:45:in `process' actionpack (3.2.8) lib/action_controller/metal.rb:203:in `dispatch' actionpack (3.2.8) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch' actionpack (3.2.8) lib/action_controller/metal.rb:246:in `block in action' actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:73:in `call' actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:73:in `dispatch' actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:36:in `call' journey (1.0.4) lib/journey/router.rb:68:in `block in call' journey (1.0.4) lib/journey/router.rb:56:in `each' journey (1.0.4) lib/journey/router.rb:56:in `call' actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:600:in `call' omniauth (1.1.3) lib/omniauth/strategy.rb:394:in `call_app!' omniauth-identity (1.1.0) lib/omniauth/strategies/identity.rb:36:in `other_phase' omniauth (1.1.3) lib/omniauth/strategy.rb:176:in `call!' omniauth (1.1.3) lib/omniauth/strategy.rb:157:in `call' omniauth (1.1.3) lib/omniauth/strategy.rb:177:in `call!' omniauth (1.1.3) lib/omniauth/strategy.rb:157:in `call' omniauth (1.1.3) lib/omniauth/strategy.rb:177:in `call!' omniauth (1.1.3) lib/omniauth/strategy.rb:157:in `call' omniauth (1.1.3) lib/omniauth/builder.rb:48:in `call' actionpack (3.2.8) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call' rack (1.4.5) lib/rack/etag.rb:23:in `call' rack (1.4.5) lib/rack/conditionalget.rb:25:in `call' actionpack (3.2.8) lib/action_dispatch/middleware/head.rb:14:in `call' actionpack (3.2.8) lib/action_dispatch/middleware/params_parser.rb:21:in `call' actionpack (3.2.8) lib/action_dispatch/middleware/flash.rb:242:in `call' rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context' rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call' actionpack (3.2.8) lib/action_dispatch/middleware/cookies.rb:339:in `call' activerecord (3.2.8) lib/active_record/query_cache.rb:64:in `call' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in `call' actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call' activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `_run__19373668__call__508978036__callbacks' activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback' activesupport (3.2.8) lib/active_support/callbacks.rb:385:in `_run_call_callbacks' activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks' actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:27:in `call' actionpack (3.2.8) lib/action_dispatch/middleware/reloader.rb:65:in `call' actionpack (3.2.8) lib/action_dispatch/middleware/remote_ip.rb:31:in `call' better_errors (0.9.0) lib/better_errors/middleware.rb:84:in `protected_app_call' better_errors (0.9.0) lib/better_errors/middleware.rb:79:in `better_errors_call' better_errors (0.9.0) lib/better_errors/middleware.rb:56:in `call' actionpack (3.2.8) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call' actionpack (3.2.8) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call' railties (3.2.8) lib/rails/rack/logger.rb:26:in `call_app' railties (3.2.8) lib/rails/rack/logger.rb:16:in `call' actionpack (3.2.8) lib/action_dispatch/middleware/request_id.rb:22:in `call' rack (1.4.5) lib/rack/methodoverride.rb:21:in `call' rack (1.4.5) lib/rack/runtime.rb:17:in `call' activesupport (3.2.8) lib/active_support/cache/strategy/local_cache.rb:72:in `call' rack (1.4.5) lib/rack/lock.rb:15:in `call' actionpack (3.2.8) lib/action_dispatch/middleware/static.rb:62:in `call' railties (3.2.8) lib/rails/engine.rb:479:in `call' railties (3.2.8) lib/rails/application.rb:223:in `call' rack (1.4.5) lib/rack/content_length.rb:14:in `call' railties (3.2.8) lib/rails/rack/log_tailer.rb:17:in `call' thin (1.5.1) lib/thin/connection.rb:81:in `block in pre_process' thin (1.5.1) lib/thin/connection.rb:79:in `catch' thin (1.5.1) lib/thin/connection.rb:79:in `pre_process' thin (1.5.1) lib/thin/connection.rb:54:in `process' thin (1.5.1) lib/thin/connection.rb:39:in `receive_data' eventmachine-1.0.3-x86 (mingw32) lib/eventmachine.rb:187:in `run_machine' eventmachine-1.0.3-x86 (mingw32) lib/eventmachine.rb:187:in `run' thin (1.5.1) lib/thin/backends/base.rb:63:in `start' thin (1.5.1) lib/thin/server.rb:159:in `start' rack (1.4.5) lib/rack/handler/thin.rb:13:in `run' rack (1.4.5) lib/rack/server.rb:268:in `start' railties (3.2.8) lib/rails/commands/server.rb:70:in `start' railties (3.2.8) lib/rails/commands.rb:55:in `block in ' railties (3.2.8) lib/rails/commands.rb:50:in `tap' railties (3.2.8) lib/rails/commands.rb:50:in `' script/rails:6:in `require' script/rails:6:in `' Started POST "/__better_errors/51402684/variables" for 127.0.0.1 at 2013-07-16 15:05:15 -0400 Started GET "/messages" for 127.0.0.1 at 2013-07-16 15:05:29 -0400 Processing by MessagesController#index as HTML User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 2]] Message Load (1.0ms) SELECT "messages".* FROM "messages" WHERE "messages"."to_user_id" = 2 User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 1]] (0.0ms) SELECT COUNT(*) FROM "messages" WHERE "messages"."to_user_id" = 2 Rendered messages/index.html.erb within layouts/application (3.0ms) Category Load (0.0ms) SELECT "categories".* FROM "categories" Location Load (0.0ms) SELECT "locations".* FROM "locations" Rendered shared/_create_project.html.erb (26.0ms) CACHE (0.0ms) SELECT "categories".* FROM "categories" CACHE (0.0ms) SELECT "locations".* FROM "locations" Rendered shared/_create_project.html.erb (3.0ms) Rendered shared/_header.html.erb (32.0ms) Rendered shared/_footer.html.erb (0.0ms) Rendered shared/_login-modal.html.erb (1.0ms) Completed 200 OK in 88ms (Views: 85.3ms | ActiveRecord: 1.0ms) ...
我/etc/apache2/sites-available/dev.myappname.com文件已啓用,服務器已重新啓動,並且它具有以下信息:
服務器名dev.myappname.com 的DocumentRoot/SRV/myappname /公共 選項-MultiViews -Indexes 允許所有 PassengerResolveSymlinksInDocumentRoot上 RailsBaseURI/myappname
這裏是我的應用程序/視圖/消息/ index.html.erb,W HICH在錯誤(幾乎軌道默認)提到:
<h1>Listing messages</h1>
<table>
<tr>
<th>From user</th>
<th>Subject</th>
<th>Message</th>
<th>Replied</th>
<th></th>
<th></th>
<th></th>
</tr>
<% if @messages.count > 0 %>
<% @messages.each do |message| %>
<tr>
<td><%= link_to @users[message.from_user_id].display_name, user_url(message.from_user_id) %></td>
<td><%= message.subject %></td>
<td><%= message.message %></td>
<td><%= message.replied %></td>
<td><%= message.project_id %></td>
<td><%= link_to 'Show', message %></td>
<td><%= link_to 'Edit', edit_message_path(message) %></td>
<td><%= link_to 'Destroy', message, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
<% else %>
<tr><td colspan="7"><i>No messages yet!</i></td></tr>
<% end %>
</table>
<br />
<%= link_to 'New Message', new_message_path %>
這裏是我的郵件#指數:
def index
# only run this page if signed in
if signed_in? == false
redirect_to root_url
return
end
@messages = Message.where(:to_user_id => current_user.id)
@users = {}
@messages.each do |msg|
user = User.find(msg.from_user_id)
@users[user.id] = user
end
#@messages = Message.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @messages }
end
end
我的大部分資產(SCSS,JS和圖像文件)在我的Rails應用程序的/ app/assets文件夾中,而不是公共的。我查看了日誌中的運行時錯誤,但我無法理解它。它在當地也很完美。
有沒有人有什麼想法我做錯了?
讀取日誌,它說錯誤在'app/views/messages/index.html.erb:17'中。那麼你能分享一下這個觀點的摘錄嗎? – cortex
我剛剛發佈了該視圖的全文;我只是使用rails g scaffold,並且它仍然是默認的索引文件。 – Lee
它是在Webrick還是瘦?您的'messages_controller'中的'index'操作將會很有幫助。 – cortex