Hi all,
Thought I''d take advantage of the newbie-friendly and quick replies to
ask a "best practise" question!
Following from my previous setup, supposing I have a Task which is
assigned_to a User.
In a view, I want to display the assigned_to user''s username. I would
use something like @task.assigned_to.username, but because the
assigned_to attribute can be nil, that would cause an error in those cases.
One solution would be to put a method in the Task helper and use that,
which would either return "Nobody" or the user''s username
(probably
linking through to controller user, action show). But I have the same
issue elsewhere.
So, is the best thing to do is add the method to the application''s
helper? Or in the User controller? Or somewhere else completely?
Regards,
Carl.