Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5940355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:57:24+00:00 2026-05-22T15:57:24+00:00

Currently my code results in a view that looks like this: Lessons Start Now!

  • 0

Currently my code results in a view that looks like this:

Lessons Start Now!
x
x
x
x
x
x

(where x = image)

I was wondering how I can make it display like this:

Lessons Start Now!
x   x   x
x   x   x

Here is my code for the index.html.erb

<h1>Lessons Start Now!</h1>
<% @lessons.each do |lesson| %>
    <%= image_tag(lesson.image, :size => "100x50") %><br />
    <%= lesson.subject %><br />
<% end %>
<%= link_to 'New Lesson', new_lesson_path %>

The only thing I can think of is writing a for loop that has a count. It will insert the first images into one div class then once the count = 3, it would insert the next 3 into a different div. Maybe something special can be done using ul and li, or perhaps there is a rails way, any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:57:25+00:00Added an answer on May 22, 2026 at 3:57 pm

    You have to use CSS to do what you desire, let’s say this is your template:

    <h1>Lessons Start Now!</h1>
    <% unless @lessons.empty? %>
    <ul class="lessons">
    <% @lessons.each do |lesson| %>
        <li>
        <%= image_tag(lesson.image, :size => "100x50", :class => "thumbnail") %>
        <p class="subect"><%= lesson.subject %></p>
        </li>
    <% end %>
    </ul>
    <% end %>
    <%= link_to 'New Lesson', new_lesson_path %>
    

    And this would be your CSS then:

    .lessons {
      /* this is needed for the parent 
         to have height. read more 
         http://css-tricks.com/all-about-floats/
      */
      overflow:hidden;
      /* adjust width of this element
         if its width is not limited by its parent
      width: 300px;
      */
    }
        .lessons li {
            /* add margins and paddings as you wish */
            float:left;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My code currently looks like this: private Foo myFoo; public Foo CurrentFoo { get
My code currently looks like this: <div style=position: fixed; width: 35.25%; height: 6.75%; left:
I am currently parsing some xml that looks like this <Rows> <Row MANUFACTURERID=76 MANUFACTURERNAME=Fondont
I currently have code in objective C that can pull out an integer's most
here is my current line of code: $(<li>).text($(this).text()).appendTo(#theList); Which results in <ul id=theList> <li>blah</li>
Currently this code generates a colored hyperlink to an ad listing on my site.
I currently have code that does the following: private final static ExecutorService pool =
I have a class that conforms to UISearchDisplayDelegate and contains a UISearchBar. This view
I've got some code like this: Activity[] GetAllActivities() { using (ScheduleContext ctx = new
I have a webview that performs a search, this code works great for below

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.