【发布时间】:2018-12-18 05:47:53
【问题描述】:
您好,我是 Ror 的新手, 在我的新应用上,我使用 cloudinary 和 attachinary gem 在我的产品页面上显示我的照片。 我没有成功在我的展示页面上只显示与我的产品相对应的第一张照片,而不是我的所有产品照片。 有没有什么云里雾里的帮手说我想在这个地方展示product.picture 1 或product.picture 2? 感谢您的帮助,
这是我的代码: 课程.html.erb
<% @lesson.photos.each do |photo| %>
<%= cl_image_tag photo.path, width: 400, height: 200, crop: :fill %>
<% end %>
_form.html.erb:
<%= simple_form_for(@lesson) do |f| %>
<%= f.input :name %>
Photo 1 <%= f.input :photo %>
<%= f.input :photo_cache, as: :hidden %><br>
Photo 2 <%= f.input :photo %>
<%= f.input :photo_cache, as: :hidden %><br>
<%= f.button :submit %>
<% end %>
【问题讨论】:
-
你用什么上传照片?回形针还是载波?
-
我用的是carrierwave
-
你试过了吗:
<%= image_tag photo_url, width: 400, height: 200, crop: :fill %>,因为这是使用carrierwave时显示图像的方式 -
这也不好用 :-(
标签: ruby-on-rails image helper cloudinary