我在 rails 3.2.1 中显示 flash :notice 时遇到问题。这是我的代码
class AssetsController < ApplicationController
before_filter :authenticate_user!
before_filter :user_can_upload, :only => [:new, :add_image]
#...actions
def new
@asset = Asset.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @asset }
end
end
private
def user_can_upload
if current_user.can_upload?
redirect_to dashboard_index_path, notice: I18n.t(:quota_assets)
end
end
end
在我的主要布局中
%body
= render 'layouts/shared/header'
-if notice
.container
.alert.alert-success=raw notice
= yield
例如,在新操作中重定向工作正常,但没有显示通知消息。有什么提示吗?谢谢