2014-09-22 122 views
2

我在4.0.x中使用了帶拉鍊的導軌,它完美地工作以通過渲染渲染正確的結果在rabl模板和錯誤中:json => {:error =>'哦不! 「}。Rails 4.1升級導致丟失模板

我用

ActionController::Metal and 
    include ActionController::ForceSSL 
    include ActionController::Redirecting 
    include ActionController::Rendering 
    include ActionController::RequestForgeryProtection 
    include ActionController::Renderers::All 
    include ActionController::MimeResponds 
    include ActionController::ImplicitRender 
    include AbstractController::Callbacks 
    include Devise::Controllers::Helpers 
    include ActionController::StrongParameters 
    protect_from_forgery with: :null_session 
    append_view_path "#{Rails.root}/app/views" 

通過升級到4.1,我不得不改變的ActionController ::渲染到一個AbstractController ::渲染和包括::的ActionView佈局。

問題:沒有ActionView ::佈局我可以渲染:json => {something}但我的模板沒有加載。使用ActionView :: Layouts我得到每個渲染:json => {...}一個Missing Template錯誤。

任何提示表示讚賞!

+0

我不知道有足夠的瞭解Rabl的,而只是一個不過,你還相信也升級Rabl的寶石最新的,或者至少是一個陳述與Rails 4.1兼容? – 2014-09-22 17:31:59

+0

當我從ActionController :: Base繼承我的控制器時,兩種情況都可以正常工作。我不認爲這個問題與拉布寶石有關,但我的包括。 – schangli 2014-09-22 17:42:09

回答

1

好的,我想通了。這是我包含的順序,而不是用AbstractController替換ActionController :: Rendering :: Rendering我應該添加它。

工作順序和名單:

include AbstractController::Rendering 
include ActionController::Redirecting 
include ActionView::Layouts 
include ActionController::Rendering 
include ActionController::Renderers::All 
include ActionController::MimeResponds 
include ActionController::ImplicitRender 
include ActionController::StrongParameters 
include ActionController::RequestForgeryProtection 
include ActionController::ForceSSL 
include AbstractController::Callbacks 
include Devise::Controllers::Helpers