Part 5: Editing our table
Our table looks pretty good already, but let’s say we want to make it even better by changing the column headers, and having the titles not be capitalized.
- To change the column headers, we need to specify the new names within the
<fields>
tag. We do that by addingas (name)
after the column name, where,(name)
can be whichever header name we want. Modify the XML-template to include some names of your choosing.
- Now we will make the title fields look better, by improving their capitalization. We can do this by using the
<edit>
tag. It allows us to run Ruby methods on the fields before displaying them. A very useful method for our usecase istitleize
. This method makes text look like a title, by capitalizing the first letter of every word. To use the<edit>
tag we write on the formatfieldname.method_to_perform
within it.
Note that we had to use the name we gave in step 1 to perform the edit. This is because the as
keyword renames the variable itself.
- That’s it! Now our table looks even better!