资产管道中不存在资产“课程/ python”?

时间:2019-12-18 03:02:06

标签: ruby-on-rails

做一个简单的Rails项目,当我尝试在localhost:3000上运行它时,出现错误:

ActionView::Template::Error (The asset "courses/python" is not present in the asset pipeline.):
 5:<div class="card">
 6:<div class="card-image">
 7:<%= link_to course do %>
 8:<%= image_tag "courses/#{course.image}" %>
 9:<% end %>
10:</div>
11:<div class="card-content">app/views/pages/home.html.erb:8app/views/pages/home.html.erb:7app/views/pages/home.html.erb:3

1 个答案:

答案 0 :(得分:0)

  1. 以这种方式放置图像目录app/assets/images/courses/course_image.jpg
  2. 将其包含在application.css之类的//= require courses文件中
  3. 之后,您可以在视图中使用它,例如<%= image_tag "courses/course_image.jpg" %>

有关资产管道here

的更多信息