0

私が使用している: Rails 3.1.3、HAML、および Passenger

ステージング ブランチでルートの問題が発生していますが、ステージングにマージされた他のブランチではまったく問題がありません。これら 2 つのブランチのルート ファイルとフォーム ファイルを比較してみましたgit diffが、ブランチ内の 2 つのファイルは同じです。

奇妙なことは、レンダリングされたエラー ページです。ここにスクリーンショットへのリンクがあります

エラーメッセージ

また、乗客からのエラー:

Rendered time_entries/_form_fields.haml (173.2ms)
Rendered time_entries/_form.haml (194.7ms)
Rendered time_entries/edit.haml within layouts/application (196.6ms)
Completed 500 Internal Server Error in 448ms

ActionView::Template::Error (No route matches {:controller=>"time_entries"}):
    5:     .field
    6:       = form.submit "Save"
    7:       |
    8:       = link_to "Cancel", project_time_entries_path(@project)
  app/views/time_entries/_form.haml:8:in `block in     _app_views_time_entries__form_haml__894171410_105032920'
  app/views/time_entries/_form.haml:3:in   `_app_views_time_entries__form_haml__894171410_105032920'
  app/views/time_entries/edit.haml:2:in `_app_views_time_entries_edit_haml__805073897_105087770'

ルートとフォームのコードを添付します

フォーム.haml

.app-form
  = error_messages_for :time_entry
  = form_for [@project, @time_entry] do |form|
    = render :partial => 'form_fields', :locals => {:form => form}
    .field
      = form.submit "Save"
      |
      = link_to "Cancel", project_time_entries_path(@project)

ルート.rb

Titi::Application.routes.draw do

  root :to => 'time_entries#index'
  match 'home' => 'home#index', :as => :home

  match '/api/*other' => TitiAPI

  resources :projects do
    member do
      get 'archive'
      get 'unarchive'
    end

    resources :viewers
    resources :labels

    resources :time_entries do
      collection do
        get 'start'
      end
      member do
        get 'new_note'
        put 'add_note'
      end
    end

  end

  resources :bookings

  resources :technical_orientations, except: [:delete]

  match 'merge_labels/:projects_id' => 'labels#merge_labels', :as => :merge_labels
  match 'move_labels/:projects_id' => 'labels#move_labels', :as => :move_labels

  resources :time_entries do
    collection do
      get 'start'
    end

    member do
      get 'new_note'
      put 'add_note'
    end
  end

  resources :users do
    member do
      get 'time_entries'
      get 'edit_password'
      put 'update_password'
      get 'suspend'
      get 'unsuspend'
    end

    new do
      get 'invite_form'
      post 'invite'
    end

    collection do
      get 'all'
    end
  end

  resources :user_sessions

  match 'reports/timesheet' => 'reports#timesheet', :as => :timesheet
  match 'reports/:week/timesheet' => 'reports#timesheet', :as => :timesheet_week
  match 'reports/timesheet_detail' => 'reports#timesheet_detail', :as =>     :timesheet_detail
  match 'reports/dashboard' => 'reports#dashboard', :as => :dashboard_report
  match 'reports/timeentries_irregulars' =>    'time_entries_irregulars#timeentries_irregulars', :as => :timeentries_irregulars
  match 'reports/:week/timeirregulars' => 'time_entries_irregulars#timeentries_irregulars', :as => :timeirregulars_week

  match 'reports/timesheet/admin' => 'reports#timesheet_admin', :as => :timesheet_admin
  match 'reports/:week/timesheet/admin' => 'reports#timesheet_admin', :as => :timesheet_admin_week

  match 'reports/time_entries' => 'time_entries_reports#landing_report'
  match 'reports/time_entries/make' => 'time_entries_reports#index'
  match 'reports/time_entries/csv' => 'time_entries_reports#make_csv'

  match 'reports/:token' => 'reports#index', :as => :reports

  match 'login' => 'user_sessions#new', :as => :login
  match 'logout' => 'user_sessions#destroy', :as => :logout
  match 'register' => 'users#register', :as => :register

  resources :companies do
    collection do
      get 'settings'      
      get "remove_photo"
    end
  end  

  match 'labels/for_project_id/:id' => 'labels#for_project_id', :as => :for_project_id

  match 'holidays_for_company/:token' => 'holidays#public', :as => :public_holiday_for_company
  match 'holidays_by_year' => 'holidays#by_year', :as => :holidays_by_year

  resources :holidays 
  resources :clients

  resources :invoices do
    member do
      get 'pdf_invoice'
      get 'cancel'
    end
    resources :invoice_lines do
      collection do
        get 'add'
      end
    end
    resources :payments
  end

  resources :tweets do
    resource :tweet_likes, :path => 'likes' do
      collection do
        get 'names'
      end
    end
  end

  match 'select_invoices' => 'invoices#select_invoices', :as => :select_invoices

  match 'pusher/auth' => 'pusher#auth'

  resources :requests, :only=>[:create]
  match  '*request', :controller => 'requests', :action => 'options', :constraints => {:method => 'OPTIONS', :format => 'json'}
end

前もって感謝します。

4

1 に答える 1

0

app/views/time_entries/_form.haml:8 に @project は存在​​しますか? ステージング ブランチが別のデータベースを使用しているため、存在すると思われる @project が存在しない可能性があります。

また、rake routes を実行し、project_time_entries が出力に含まれていることを確認します。おそらく、ルートの 1 つに :as が必要です。

于 2012-11-03T15:53:40.070 に答える