2012-11-03 26 views
0

我使用的是:Rails的3.1.3,HAML和Rails 3的路由錯誤,但不是在其他

我有我的分期分支路線問題客運,但在其他分支被合併到分期我沒有任何問題。我嘗試過使用git diff來比較我的路線文件和來自這兩個分支的表單文件,但這兩個文件在分支中是相同的。

奇怪的是呈現的錯誤頁面。下面是一個屏幕截圖

Error message

而且也是錯誤的鏈接從乘客:

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' 

我附上你從我的路線的代碼和我的形式

form.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) 

routes.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 

提前致謝。

回答

0

關於app/views/time_entries/_form.haml:8,@project是否存在?也許你的staging分支使用不同的數據庫,因此你認爲@project沒有?

另外,運行rake路由並驗證project_time_entries是否在輸出中。也許你需要一個:如你的路線之一。

+0

它使用相同的數據庫,我跑耙路線和路線存在。正如你在我的routes.rb中看到的那樣,路由是被定義的。很奇怪,對吧? – edelpero