Ruby on Rails Wednesday, August 11, 2010

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.
2) how do I grab the initials method ?
--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment