0

私のフォルダの構造は次のとおりです。ルートは /home3/username です。

私の Web アプリは 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 のコンテンツを正しく表示しますが、[Manage Projects] ボタンをクリックするとこのエラーが発生します

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 フォルダーの下にあることを除いて、これと非常によく似た別の Web アプリがあるため、これはルーティングの問題だと思いますが、修正できないようです。

誰か助けてくれませんか?

4

1 に答える 1

0

デフォルトではフォームがPOSTリクエストを発行するため、フォームはプロジェクトコントローラーの作成アクションに移動すると思います。

フォームにgetリクエストを発行するように指示するこのようなものを試してみてください。これにより、インデックスアクションが実行されます。

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

しかし、私があなたなら、おそらくリンクを使用して、cssを使用してボタンのようにスタイルを設定します。

于 2012-09-18T05:56:36.810 に答える