ruby-on-rails-5 - Ruby on Rails / 资产管道为空
问题描述
我正在使用 Rails 5.2 我正在尝试访问图像的路径,如下所示:
<%= image_path(@pin.image)%>
我在终端中收到以下错误消息。
我是不是忘了在 config.assets.paths 中设置一些东西?或链轮设置错误?
在 2018-07-18 20:53:06 +0900 (1.0ms) 开始 GET "/pins/2" for 127.0.0.1 SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC ↳ /Users/computer/.rvm/gems/ruby-2.4.0/gems/activerecord-5.2.0/lib/active_record/log_subscriber.rb:98 PinsController 处理#show as HTML 参数:{"id"=> "2"} 引脚负载 (0.2ms) 选择 "pins".* FROM "pins" WHERE "pins"."id" = ? 限制 ?[["id", 2], ["LIMIT", 1]] ↳ app/controllers/pins_controller.rb:67 在布局/应用程序中渲染 pin/show.html.erb ActiveStorage::Attachment Load (0.2ms) SELECT " active_storage_attachments".* FROM "active_storage_attachments" WHERE "
ActionView::Template::Error(资产“”不存在于资产管道中。):
6: </p>
7:
8: <%= image_tag(@pin.image) %>
9: <%= image_path(@pin.image)%>
10:
11:
12:
app/views/pins/show.html.erb:9:in `_app_views_pins_show_html_erb__253993838852336219_70195426237620'
解决方案
我刚刚通过使用解决了我的问题:
<%= rails_blob_url(@pin.image)%>
这是正确的方法吗?
推荐阅读
- apache - 无法在 windows 服务器中启动 apache tomcat 服务
- javascript - Windows.location.reload() 在 hostgator 中托管的 react js 应用程序中不起作用
- python - 尝试将 CSV 加载到 JSON 格式。似乎只在 JSON 中指定了 CSV 的最后一行
- java - Spring Security OAuth2 在 REST 服务上被拒绝访问
- java - 有没有办法在 log4j 模式中指定当前行号
- opentbs - 在 OpenTBS 演示中,图像被替换,这是在哪里完成的?
- sql-server - 从中选择时如何加快从大表数据中检索数据的速度?
- php - 当图中的节点包装器时,PHP domDocument 工作不正确?
- php - 如何测试/查看 PHP 脚本的内存占用?
- python - Pandas DataFrame 中值函数