0

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

たとえば、新しいアクションのリダイレクトは正常に機能しますが、通知メッセージは表示されません。ヒントはありますか?ありがとうございました

4

1 に答える 1

1

フラッシュメッセージを出力したい場合は、flash[:notice]notを使用する必要があると思いますnotice

于 2013-03-11T07:55:31.693 に答える