Scaffolding Results Format

Hi Everyone,

I built a scaffold and I’m having trouble getting results properly
formatted. (I need to get the data into multiple columns instead of just
one big column) I can’t get all of my CSS to work properly in
scaffold.css, layout/books.rhtml, or the books/index.rhtml.erb Anyways,
maybe you have a suggestion.

Default view (127.0.0.1:3000/books)

Title Abstract
Book One Book One Abstract Show Edit Destroy
Book Two Book Two Abstract Show Edit Destroy
Book Three Book Three Abstract Show Edit Destroy


View I would like to see displayed (127.0.0.1:3000/books):

Book One Book Two Book Three
Book One Abstract Book Two Abstract Book Three
Abstract
Show Edit Destroy Show Edit Destroy Show Edit Destroy


I’ve tried editing scaffold.css, layouts/books.rhtml.erb, and
books/index.rhtml.erb but can only achieve this result:

Book One
Book One Abstract
Show Edit Destroy
Book Two
Book Two Abstract
Show Edit Destroy
Book Three
Booth Three Abstract
Show Edit Destroy


Am I missing something in books_controller.rb? Thanks for your help!

On Wed, May 27, 2009 at 4:16 AM, Jay C. <
[email protected]> wrote:

Default view (127.0.0.1:3000/books)

Book One Book Two Book Three
Book One Abstract Book Two Abstract Book Three
Abstract
Show Edit Destroy Show Edit Destroy Show Edit Destroy

The presentation of the output you would like to have is very confusing
at best. For example, what does edit and destroy links do at the bottom
of each table? Do they operate on all of the entries? You might want
to
clarify what you’re really trying to do with this type of structure.

-Conrad

[snip]

Conrad T. wrote:

On Wed, May 27, 2009 at 4:16 AM, Jay C. <
[email protected]> wrote:

Default view (127.0.0.1:3000/books)

Book One Book Two Book Three
Book One Abstract Book Two Abstract Book Three
Abstract
Show Edit Destroy Show Edit Destroy Show Edit Destroy

The presentation of the output you would like to have is very confusing
at best. For example, what does edit and destroy links do at the bottom
of each table? Do they operate on all of the entries? You might want
to
clarify what you’re really trying to do with this type of structure.

-Conrad

[snip]


By default, scaffold displays data into rows it seems. Disregard the
“Show” “Edit” “Destroy” links as they are just the generic actions
produced by creating the scaffold. All I’m trying to do is get the
127.0.0.1:books to display the data in multiple columns instead of just
one.

Book One Book Two Book Three
Book One Abstract Book Two Abstract Book Three Abstract

Book Four Book Five Book Six
Book Four Abstract Book Five Abstract Book Six Abstract

Ar Chron wrote:

Take a look at the in_groups_of method for your list processing in the
view…

@books.in_groups_of(3) do |group|
start row
group.each.do |book|
start column
book.title + ‘’ + book.abstract
end column
end
end row
end

or something like that…

Thanks Ar Chron! That is the right method. Railscast #28 discusses this
in_groups_of method for anyone encountering the same problem.

Take a look at the in_groups_of method for your list processing in the
view…

@books.in_groups_of(3) do |group|
start row
group.each.do |book|
start column
book.title + ‘’ + book.abstract
end column
end
end row
end

or something like that…