names and stuff

I'm trying to stuff like this in my BabyName model..

  before_save :capitalize

  def capitalize     self.title = title.capitalize     self.forename = forename.capitalize     self.surname = surname.capitalize     self.middlenames = middlenames.split.each { |x| print x.capitalize!, " "}.join(" ")   end

  def full_name     self.title + " " + self.forename + " " + self.middlenames + " " + self.surname   end

  def initials

  end

I'm trying to stuff like this in my BabyName model..

before_save :capitalize

def capitalize self.title = title.capitalize self.forename = forename.capitalize self.surname = surname.capitalize self.middlenames = middlenames.split.each { |x| print x.capitalize!, " "}.join(" ") end

def full_name self.title + " " + self.forename + " " + self.middlenames + " " + self.surname end

def initials

end

#

two things;

1) my full_name method doens't seem great in that I might get two spaces between names.

You could build an array with all the components, remove any blanks or nils and then use join on all that

2) how do I grab the initials method ?

as in how to write it ? forename & surname should be straightforward, for middlenames you could just split on spaces and then take the first letter of each component

Fred