@trainer = Trainer.new(trainer_params)
@trainer.name = @trainer.name.humanize
@trainer.surname = @trainer.surname.humanize
This bit works fine, but I would also like to apply the same thing to Sportist
which belongs_to :trainer
and
@trainer.sportists.name = @trainer.sportists.name.humanize
doesn't work, so how would I go about doing it? Note that this is a nested form
.
If @trainer.sportists
is a collection (an has_many
relation ?), try this:
@trainer.sportists.each { |sportist| sportist.name = sportist.name.humanize }