Skip to content

Instantly share code, notes, and snippets.

@sandys
Created March 18, 2011 07:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sandys/875737 to your computer and use it in GitHub Desktop.
Save sandys/875737 to your computer and use it in GitHub Desktop.
random tidbits about rails

You need to create a getter and setter method to create a virtual attribute

 def full_name
  [first_name, last_name].join(' ')
 end

 def full_name=(name)
  split = name.split(' ', 2)
  self.first_name = split.first
  self.last_name = split.last
 end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment