2014-01-21 83 views
1

我試圖顯示此錯誤消息,但它不會出現時呈現404 Redmine頁面。我做錯了什麼?功能閃光燈不工作reder_404紅寶石1.3紅寶石紅寶石1.8.7 Rails 2.3.14

感謝先進!

這是我的代碼:

 

def file_readable 

    if @attachment.readable? 
     true 
    else 
     flash.now[:error] = "This file has been removed" 
     render_404 
    end 
    end 

紅寶石紅寶石1.8.7(2012-02-08 PATCHLEVEL 358)

的Rails 2.3.14

 

** LOCAL GEMS ** 

actionmailer (2.3.14) 
actionpack (2.3.14) 
activerecord (2.3.14) 
activeresource (2.3.14) 
activesupport (2.3.14) 
color (1.4.1) 
daemon_controller (1.0.0) 
fastthread (1.0.7) 
i18n (0.4.2) 
icalendar (1.2.1) 
json (1.7.5) 
mime-types (1.19) 
mysql (2.8.1) 
passenger (3.0.13) 
pdf-writer (1.1.8) 
rack (1.1.3) 
rails (2.3.14) 
rake (10.1.1, 0.8.7) 
rdoc (3.12) 
transaction-simple (1.4.0.2) 

+0

什麼方法'#render_404'? –

+0

渲染404錯誤頁面 – Carlos

+0

驗證,錯誤文本是否存在於生成的頁面上?然後嘗試呈現非404錯誤頁面,並提供結果。 –

回答

0

編輯

我以前的回答錯了,因爲我誤解了這個問題。請參考this code

我想顯示自定義消息的正確方式如下:

render_404 :message => "This file has been removed" 
+0

不總是,flash shell在任何情況下都可以工作。 –

+0

感謝您的回答,但此解決方案無法正常工作。 – Carlos

+0

你的解決方案看起來不錯,但閃存仍然不工作... – Carlos