SELECT 'rails generate scaffold '|| initcap(table_name) || ' ' ||
(select array_to_string(array(
SELECT column_name || ':' || case
when data_type='timestamp without time zone' then 'timestamp'
when data_type='character varying'then 'string'
else data_type end
FROM information_schema.columns
WHERE table_schema = 'public' and table_name = table_name order by column_name ), ' ') )
FROM information_schema.tables WHERE table_schema='public'