Rails f 中的闪存消息不再显示



>我应该提到它们在几个提交之前就出现了。自从他们停止工作以来,我知道我已经添加了用于付款的 Stripe 和用于发送传真的 efax。我忽略了这个问题几次提交,因为我专注于其他事情,认为这将是一个快速解决方案,但是我无法弄清楚。

我不认为这是我调用闪存消息的格式 - 为了给出一个想法,这是我在其中一个控制器中的创建操作之一:

  def create
     @vendor = @company.vendors.build(vendor_params)    
     respond_to do |format|
  if @vendor.save
    format.html { redirect_to vendors_url, notice: 'Vendor was successfully created.' }
    format.json { render :show, status: :created, location: @vendor }
  else
    format.html { render :new }
    format.json { render json: @vendor.errors, status: :unprocessable_entity }
  end
end

结束

我尝试更改格式,并翻转"通知:"和"redirect_to"但没有成功,但这是曾经工作的原始格式。

这是我的应用程序布局,采用haml格式(缩进与我的代码相同,以防这是某处的问题)

%html
%head
    - unless user_signed_in?
        %title Welcome to Swiftorders
    - else
        %title
            ="#{@company.name} ~ Swiftorders"
    = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
    = javascript_include_tag 'https//js.stripe.com/v2/', 'application', 'data-turbolinks-track' => true
    %script{:src => "//use.typekit.net/odj6wem.js"}
    :javascript
        try{Typekit.load();}catch(e){}
    = csrf_meta_tags
    = tag :meta, :name => :secret_key, :content => :publishable_key
- unless user_signed_in?
    %body.splash
    .logo
    = yield
- else
    %body
    .app-wrapper.clear
        - if flash[:notice]
            %p.notice
                = :notice
        - if flash[:alert]
            %p.alert
                = alert
        = render "layouts/sidebar"
        .content
            = render "layouts/header"
            .sheet
                = yield

最后,这是相关的CSS代码,p.notice(它是一个css.sass文件):

p.notice
    position: absolute
    opacity: 0.7
    margin: 0px
    bottom: 0
    z-index: 99
    width: 100%
    text-align: center
    font-size: 18px
    font-weight: 300
    padding: 20px
    color: #fff
    background: #000

根据我对 Rails 的有限理解,我认为没有其他任何东西会影响 flash 消息 - 除非可能存在我在某处关闭并且没有意识到的配置?

如果需要,我可以发布更多代码,但现在我不知道还能在哪里看。

谢谢大家!

注意= :notice= alert

预期flash[:notice]flash[:alert]

我想通了——我把"config.middleware.use ActionDispatch::Cookies" 和"config.middleware.use ActionDispatch::Session::CookieStore"在我的application.rb文件中修复了另一个问题,注释掉这些修复了我的Flash消息。同样,= :notice使得正在闪烁的消息只是"通知",而不是预期的消息。

最新更新