This is the code in my People Controller for the Create action :
def create
@person = Person.new(person_params)
@person.branch_id = session[:branch_id]
@person.added_by = current_user.id
if @person.save
respond_to do |format|
format.json { render json: @person}
end
end
end
And I have a method in my Person Model to get the person's full name :
def full_name
[self.first_name, self.middle_name, self.last_name].reject(&:blank?).join(" ")
end
What is the best way to add the Person's full name to @person when it is returned back as a JSON object