0

show.html.erb은 세로는 div_for, 파셜 컬렉션

<%= render :partial => "hello", :collection => hello %> 

_hello.html.erb

<%= div_for hello do %> 
    <%= link_to image_tag(hello.image, :size => "75x75"), '#' %> 
    <%= hello.updated_at.strftime('%m/%d/%Y') %> 
<% end %> 

현재 부분 렌더 출력 :

hello1

hello2

원하는 출력 :

hello1 hello2 hello3 hello4

hello5 hello6 hello7 hello8

는 기본적으로 나는 열로 나란히 항목 측 렌더링 대신 당 하나 할

선. 나는 테이블을 사용하여 시도하고 divs를 플로트하는 방법을 알고 있지만 레일스가 div 클래스와 id를 생성한다는 문제가 있으며 CSS 파일을 만드는 방법을 알지 못한다. id1, id2, id3, id4, ... id200 등의 규칙이 있습니다. 특정 행의 항목을 한 줄에 입력하는 것이 더 쉬운 방법인지 궁금합니다.

답변

1

는이

<%= div_for(hello, :class => "SOMECLASS" do %> 
    <%= link_to image_tag(hello.image, :size => "75x75"), '#' %> 
    <%= hello.updated_at.strftime('%m/%d/%Y') %> 
<% end %> 

처럼 div_for하는 클래스를 추가 할 수 있습니다 그리고 당신은 플로트와 사업부의 스타일을 할 수 있습니다 div의 측면이 곁에있을 수 있도록, 왼쪽으로.