2
これは私を狂ってしまう。私は資産管理のための新しいRails 3.2.2
アプリケーションを持っています。しかし、フラッシュは常に空ですRails 3.2.2でFlashメッセージが機能しない
class AssetsController < ApplicationController
respond_to :html, :json, :xml
def index
respond_with(@assets = Asset.all)
end
def show
@asset = Asset.find(params[:id])
respond_with @asset
end
def new
@asset = Asset.new
respond_with @asset
end
def create
@asset = Asset.new(params[:asset])
if @asset.save
flash[:notice] = "Asset created successfully"
end
respond_with @asset
end
def edit
@asset = Asset.find(params[:id])
respond_with @asset
end
def update
@asset = Asset.find(params[:id])
if @asset.update_attributes(params[:asset])
flash[:notice] = "Asset updated successfully"
end
respond_with @asset
end
def destroy
# tbd...
end
end
は私application.html.erb
<% flash.each do |name, msg| %>
<div class="alert alert-<%= name == :notice ? "success" : "error" %>">
<%= msg %>
</div>
<% end %>
の一部です:
は、ここに私のコントローラです。資産モデルが正常に更新された後でも。
私はフラッシュオブジェクトをデバッグする場合、これは私が得るものです:
--- !ruby/object:ActionDispatch::Flash::FlashHash
used: !ruby/object:Set
hash: {}
closed: false
flashes: {}
now:
私が間違って何をしているのですか?
これはうんざりです。私はちょうど別の資産(場所)を作成し、フラッシュメッセージはそれで動作します!しかし、 "資産"ではありません。私はRails 3.2.2にアップグレードしました。バンドルを更新しましたか?そして、両方のコントローラを同一に変更しました(資産と場所を除いて)。なぜそれは場所であり、資産では機能しませんか?ああ。 – cbmeeks
私の推測では、 'assets'はRails 3.2の予約語かもしれません。私はこのスレッドを除いてこれを裏付ける証拠を見つけることができませんでした:http://stackoverflow.com/questions/8186183/routing-issue-with-rails-3 –