我有一個OptionsController
,其中包含一個動作account
。相應的視圖有三種形式,分別發佈到三種不同的動作:update_profile
,update_user
和change_password
。每個動作都會運行,然後應該重定向回action
,在這裏再次設置並呈現視圖。如何在維護DRY的同時將多個操作重定向到單個操作?
我試圖保持乾燥,並創建一個after_filter
做重定向:
after_filter(:only => [:change_password, :update_profile, :update_user]) do |controller|
controller.send(:redirect_to, :action => :account)
end
然而,這似乎並沒有被調用;相反,行動抱怨說它的觀點無法找到。
Template is missing
Missing template options/update_user.erb in view path app/views
有沒有什麼辦法可以幹這種方式,或者我應該堅持在這三個行動的每一個redirect_to電話?