Rails flash消息不显示

时间:2013-12-15 16:09:34

标签: ruby-on-rails

我出去了... 3个小时,但仍然没有。我在application_controller.rb中为我的应用程序创建了before_filter:

def fill_profile

unless current_user.profile.state_id.present?
  flash[:add_state] = 'add_state'
  return respond_to do |format|
    format.html { redirect_to edit_profile_path(current_user.profile) }
  end
end
end

现在,assets_controller.rb:

class AssetsController < ApplicationController

  before_filter :fill_profile

end
assets_controller中的

索引操作为空。我按链接:

<%= link_to 'abc', assets_path %>

什么也没有......没有flash消息。对于每个其他控制器,这个before_filter工作,只有assets_controller没有。有人可以帮忙吗?

在before_filter中除了这个之外没有重定向。当我只在没有redirect_to的情况下在before_filter中放入flash消息时 - 它甚至适用于assets_controller。

我也有同样的消息链接:

<%= link_to 'def', messages_path %>

和exacly相同的空messages_controller.rb只有before_filter - 和它一起工作!

查看Flash消息:

<div id="flash_messages">
  <% flash.each do |key, value| %>
    <%= render :partial => 'shared/flash_element', :locals => { :key => key.to_s.downcase, :value => value } %>
   <% end %>
 </div>

0 个答案:

没有答案