【发布时间】:2019-01-02 21:39:07
【问题描述】:
我是 rails 和 stack over flow 的新手,如果我能在这里指导,我将不胜感激。
我正在开发一个类似于个人博客的测试站点,只是为一个用户添加投资组合。
我有一个脚手架“图像”,用于在应用程序中添加图像,脚手架只有两个字段,一个用于上传图像,另一个用于摄影师姓名。
- 图像将显示在主页上 - 运行良好。
- 但是,当我单击图片时,图片会放大,用户可以使用左右箭头滚动图片。
- 我的问题 - 单击图像时,图像未获取,并显示消息“无法加载此图像。
以下是我的代码供您参考,我确定我在这一行中犯了一些错误
<a href="image_tag image.photo.url" title="<%= image.by %>" >
但是,目前还无法纠正。
任何帮助或建议都会很棒。
我的代码
<!-- start portfolio section -->
<section class="wow fadeIn">
<div class="container">
<div class="row">
<div class="col-md-12 no-padding xs-padding-15px-lr">
<div class="filter-content overflow-hidden">
<ul class="portfolio-grid work-3col hover-option4 lightbox-gallery gutter-small">
<li class="grid-sizer"></li>
<!-- start portfolio item -->
<% @images.order('created_at DESC').each do |image| %>
<li class="grid-item web branding design wow fadeInUp">
<a href="image_tag image.photo.url" title="<%= image.by %>" >
<figure>
<div class="portfolio-img bg-extra-dark-gray">
<%= image_tag image.photo.url, class: "project-img-gallery", alt: "" %>
</div>
<figcaption>
<div class="portfolio-hover-main text-center">
<div class="portfolio-hover-box vertical-align-middle">
<div class="portfolio-hover-content position-relative">
<i class="ti-zoom-in text-white fa-2x"></i>
</div>
</div>
</div>
</figcaption>
</figure>
</a>
</li>
<% end %>
<!-- end portfolio item -->
</ul>
</div>
</div>
</div>
</div>
</section>
<!-- end portfolio section -->
【问题讨论】:
-
你能打开浏览器控制台看看你得到的错误吗?
-
在布局/应用程序中渲染 home/index.html.erb 图像加载 (7.7ms) 选择“图像”。* FROM “图像” ORDER BY created_at DESC ↳ app/views/home/index.html .erb:28 在布局/应用程序中渲染 home/index.html.erb (40.8ms) 渲染 shared/_message.html.erb (2.2ms) 在 633ms 内完成 200 OK (Views: 582.3ms | ActiveRecord: 7.7ms) 开始 GET 2019-01-02 19:06:49 +0530 ActionController::RoutingError 的“/image_tag%20image.photo.url”为 127.0.0.1(没有路由匹配 [GET]“/image_tag%20image.photo.url”):
标签: ruby-on-rails ruby wow.js