How do I display SVG image in Rails?

后端 未结 7 2078
爱一瞬间的悲伤
爱一瞬间的悲伤 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:28

    Its straightforward:

    First, add the svg to the asset precompile list in assets.rb

    application.config.assets.precompile +=
        %w( symbol-defs.svg)
    

    Then reference it in your erb/haml files as shown below:

    
      
    
    

提交回复
热议问题