How do I use CSS with a ruby on rails application?

后端 未结 8 478
情书的邮戳
情书的邮戳 2020-12-01 04:00

How do I use CSS with RoR? When I link externally, I\'m never able to see the files. I cp\'d the .css file to every folder I could think of...views, controller, template, an

8条回答
  •  無奈伤痛
    2020-12-01 04:55

    Use the rails style sheet tag to link your main.css like this

    <%= stylesheet_link_tag "main" %>
    

    Go to

    config/initializers/assets.rb
    

    Once inside the assets.rb add the following code snippet just below the Rails.application.config.assets.version = '1.0'

    Rails.application.config.assets.version = '1.0'
    Rails.application.config.assets.precompile += %w( main.css )
    

    Restart your server.

提交回复
热议问题