0
@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.

Xeen
  • 6,955
  • 16
  • 60
  • 111

1 Answers1

0

If @trainer.sportists is a collection (an has_many relation ?), try this:

@trainer.sportists.each { |sportist| sportist.name = sportist.name.humanize }
Baldrick
  • 23,882
  • 6
  • 74
  • 79