LoginSignup
1
1

More than 5 years have passed since last update.

20件画像を取得して表示する!

Posted at
  <div id="main_cnt_wrapper">
    <div id="yjContentsBody">
      <div class="yjContainer">
        <span class="yjGuid"><a id="yjContentsStart" name="yjContentsStart"></a><img alt="ここから本文です" height="1" src="http://i.yimg.jp/yui/jp/tmpl/1.1.0/audionav.gif" width="1"></span>
        <div id="yjMain">
          <article class="section">
            <div class="container">
              <header class="header header--section">
                <h2 class="text-middle">
                  <i class="icon-movie color-gray-light"></i>新着作品
                </h2>
              </header>
              <ul class="thumbnails thumbnail--movies row grid4 js-lazy-load-images js-my-check-stats" id="list-module">
                <li class="col">
                  <a href=""><div class="thumbnail__figure" style="background-image:url(http://image.eiga.k-img.com/images/movie/79576/poster2/200.jpg?1410346831)"></div></a>
                  <div class="thumbnail__caption">
                    <h3 class="text-xsmall text-overflow" title="神さまの言うとおり">
                      <span><i class="icon-rate-60 text-xxsmall opacity-60" title=""></i></span>神さまの言うとおり<small 2014=""></small>
                    </h3>
                    <p class="text-small">
                      <span class="rating-star"><i class="star-actived rate-00"></i></span>
                    </p>
                  </div>
                </li>
              </ul>
            </div>
          </article>
        </div>
        <div id="yjSub">

この文を、データベースに応じて変化できるようにする。

<% @products.each do |product| %>
                <li class="col">
                  <a href=""><div class="thumbnail__figure" style="background-image:url(<%= product.image_url %>)"></div></a>
                  <div class="thumbnail__caption">
                    <h3 class="text-xsmall text-overflow" title="<% product.title %>">
                      <span><i class="icon-rate-60 text-xxsmall opacity-60" title=""></i></span><%= product.title =%><small 2014=""></small>
                    </h3>
                    <p class="text-small">
                      <span class="rating-star"><i class="star-actived rate-00"></i></span>
                    </p>
                  </div>
                </li>
              <% end %>

ちなみに@productとはコントローラーで指定したものである。

class TopController < ReviewController
    def index
      @products = Product.limit(20)
    end
end
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1