Rails 4 and Turbolinks - Meta Tags not changing

后端 未结 4 715
遥遥无期
遥遥无期 2021-02-02 17:04

I have a Rails 4 app with turbo-links enabled, but I can\'t get the meta tags to refresh when changing the page ( not a full refresh ) . I read that the meta-tags need to be inc

4条回答
  •  梦谈多话
    2021-02-02 17:48

    It's a TurboLinks Problem

    By design, Turbolinks basically keeps the of your page the same & calls the of your document via ajax if it's going to remain the same (you're using the same controller / action). It's some crazy thing to maintain application performance

    Here is a good explanation of Turbolinks


    I've had a similar problem to this with Javascript, and was able to use the Jquery-Turbolinks gem to keep JS rendering

    For your meta tags, although I don't know a solution off hand, I managed to find a decent gem you might benefit from: MetaMagic. It allows you to define meta tags in the view, kind of like how the content_block facility works. This should be loaded on every http request

提交回复
热议问题