How to include a css or javascript in an erb that is outside the layout?

后端 未结 3 557
面向向阳花
面向向阳花 2020-12-13 19:47

Sorry for the slightly noobish question, as I am writing my first rails app.

I get the idea of the layout view, but if you are using them, is there any way to includ

3条回答
  •  自闭症患者
    2020-12-13 20:18

    You can add a stylesheet tag inside the head tag of the layout by doing something like this:

    layouts/products.html.erb:

    
        
            ...
            <%= yield :css %>
            ...
        
    
    

    products/edit.html.erb

    
    <% content_for :css do
        stylesheet_link_tag 'products_edit'
    end %>
    
    

提交回复
热议问题