How do I display SVG image in Rails?

后端 未结 7 2080
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-04 16:45

I have a svg image on /app/asssets/images/symbols.svg with this as contents.



        
相关标签:
7条回答
  • 2021-01-04 17:45

    I've been trying different solutions for this, and ultimately landed on just putting the svg doc in an html.erb partial. Since svg is valid html, it works fine to just move it from assets to views.

    <%# app/views/home/index.html.erb %>
    
    <%= render partial: "svgs/some_svg.html.erb"
    

    Given

    app
    | views
    | | home
    | | | index.html.erb
    | | svgs
    | | | some_svg.html.erb
    
    0 讨论(0)
提交回复
热议问题