I am looking for a good RoR table generator (or an easy solution) that can give me a decent view of my records in a table (unstylized but proper strict XHTML).
Let’s say I have a User model and an Address model:
– A User can have many Addresses
– One address is also linked as the “primary_address”
Let’s say I have the following in my User controller
def index
@users = User.find(:all,:order => 'id ASC')
@headers = ["id","First","Last","City","State"]
@fields = [:id,:firstname,:lastname,:primary_address.city,:primary_address.state]
end
I don’t know if the array of fields would work but I think it gets the point across. Does anyone know a good gem, plugin or technique for this so that I don’t have to “repeat myself” on all my table views?
@ChrisH: Representing table using two arrays won’t give more control. I would suggest the following: table_helper
erb snippet –