how to render partial on everything except a certain action

前端 未结 3 1605
小蘑菇
小蘑菇 2020-12-12 23:09

I have a _header.html.erb partial which is where I put my navbar

on my launch page I don\'t want to display the navbar.

this is the body of appl

3条回答
  •  隐瞒了意图╮
    2020-12-12 23:35

    Replace your render with this:

    <%= render 'layouts/header' unless @disable_nav %>
    

    Then you can simply set disable_nav to true in any controller action you like:

    def landing_page
      @disable_nav = true
    end
    

    As a before_filter, which I'd encourage over the above:

    application_controller.rb

    def disable_nav
      @disable_nav = true
    end
    

    my_controller

    before_filter :disable_nav, only: [:landing_page]
    

提交回复
热议问题