0

我的文件夹具有以下结构:root 是 /home3/username

我的网络应用程序位于 rails_apps/my_app/ 下,因此我的视图位于 rails_apps/my_app/app/views 下

username@company.com [~]# ls -la rails_apps/my_app/app/views/
total 24
drwxr-xr-x 6 username username 4096 Sep 17 00:48 ./
drwxr-xr-x 8 username username 4096 Sep 13 23:13 ../
drwxr-xr-x 2 username username 4096 Sep 17 01:51 home/
drwxr-xr-x 2 username username 4096 Sep 15 08:47 layouts/
drwxr-xr-x 2 username username 4096 Sep 17 00:00 projects/
drwxr-xr-x 2 username username 4096 Sep 17 00:49 scenarios/

username@company.com [~]# ls -la rails_apps/my_app/app/views/home/
total 16
drwxr-xr-x 2 username username 4096 Sep 17 01:51 ./
drwxr-xr-x 6 username username 4096 Sep 17 00:48 ../
-rw-r--r-- 1 username username  311 Sep 17 00:14 index.html.erb
username@company.com [~]# 

username@company.com [~]# cat rails_apps/my_app/app/views/home/index.html.erb
<center><h1>my_app</h1></center>
<html>
  <head>
  </head>
  <body>
    <form action = "/projects">
      <br>
      <input type="submit" value="Manage Projects" />
    </form>
    <form action = "/scenarios">
  <br>
      <input type="submit" value="Manage Scenarios" />
    </form>
  </body>
</html>
username@company.com [~]# 

这是我的 rails_apps/my_app/config/routes.rb 文件

My_app::Application.routes.draw do

  resources :scenarios

  resources :projects do
    collection do
      get :update_fields
      get :annual_production
    end
  end

  get "home/index"

  match ':controller(/:action(/:id(.:format)))'

  root :to => 'home#index'

end

这样,我的 Web 应用程序可以正确显示文件 rails_apps/my_app/app/views/home/index.html.erb 的内容,但是当我单击“管理项目”按钮时,它会生成此错误

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@my_app.company.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

Apache Server at my_app.company.com Port 80

我相信这是一个路由问题,因为我有另一个与这个非常相似的网络应用程序,除了它直接在根目录下,而这个在 rails_apps 文件夹下,但我似乎无法修复它。

有人可以帮忙吗?

4

1 回答 1

0

我认为您的表单会将您带到项目控制器的创建操作,因为默认情况下,表单将发出发布请求。

您可能想尝试这样的事情,它会告诉表单发出获取请求,这应该会将您带到索引操作。

<%= form_tag projects_path, :method => :get do %>
  <%= submit_tag "Manage projects" %>
<% end %>

但如果我是你,我可能只是使用一个链接并将它的样式设置为使用 css 的按钮。

于 2012-09-18T05:56:36.810 回答