2016-04-09 31 views
1

控制器方法爲什麼它顯示在我的代碼缺少模板錯誤

def export 
    @customers =Customer.all 

    flash[:success] = "Script ran successfully" 
end 

我想所有的客戶導出爲CSV文件,但我收到一個缺少模板錯誤。爲什麼?在我的視圖文件夾中,我有一個按鈕。

<p><%= button_to 'export Import', scripts_export_data_path %></p> 

我想導出客戶數據到上面的按鈕。

+0

請張貼完整的錯誤跟蹤 –

+0

@PetrGazarov我有編輯自己的帖子 – user2803053

+0

http://stackoverflow.com/questions/17014912/how-to-download -a-csv-file-in-ruby-on-rails –

回答

1

您需要渲染或重定向到您想要在顯示閃存消息的行後面顯示的頁面。在下一頁加載顯示的flash消息可能是。

def export 
@customers =Customer.all 

flash[:success] = "Script ran successfully" 

redirect_to 'page/template' or.... render 'page/template' 

end