[Rails] Editing scaffold.css to Make Tables More Readable

Tadashi Shigeoka ·  Tue, November 15, 2011

I edited scaffold.css to make the table in index.html.erb of the scaffold files created in Rails 3.1 more readable.

Just having lines on the table makes it much more readable.

■ public/stylesheets/scaffold.css

.scaffold_table {
  border-collapse: collapse;
  border: 1px #DCDCDC solid;
}

.scaffold_table th {
  border: 1px #DCDCDC solid;
  padding: 5px;
}

.scaffold_table td {
  border: 1px #DCDCDC solid;
  padding: 5px;
}

After editing the CSS file, add class=‘scaffold_table’ to the table tag in the template file created by the scaffold feature to apply the styling.

■ app/views/books/index.html.erb

Listing books

That’s all.

【References】

スタイルシート[CSS]/テーブル/表の境界線を指定する - TAG index Webサイト

That’s all from the Gemba.

id Title