I am using rails 3.1.3, postgreql9.1 and ruby 1.9.3.
I would like to add a column to an existing database that is really the concatenation of two existing columns, namely; first_name and last_name.
How does one go about doing this?
The reason I want the fullname is that when it comes time to display the employees, I would like to just show the fullname, but I need the name split up into two parts for other functions.
Also part of this question is that while I only want the fullname of the employee to show on a report, I would also like the employees email and primary position to show and then to have a link, called info, which when clicked will give a detailed report on the employee showing all the attributes in the employee table.
So far, I have a rudimentary employee page.
Any reader have the patience and willingness to share some pointers, guidance and or advice on how to go about this task?
Thanks,
Tom.
If you need to create the real field in your database you can use migrations.
But in this case you can use virtiual attributes:
Create two methods in your model:
And add to your view: