4
我試着翻譯https://github.com/lifo/docrails/blob/master/activerecord/lib/active_record/associations.rb如何在ActiveRecordError上使用rails-i18n進行關聯?
在我的控制文件中我有:
@book = Book.find(params[:id])
begin
@book.destroy
rescue ActiveRecord::DeleteRestrictionError => e
flash[:error]= e.message # <<< Translate this message ?
end
這是翻譯文件我用:https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/th.rb
我怎樣寫代碼translate "#{e.message}"
?