Skip to content

Instantly share code, notes, and snippets.

@oliverbarnes
Created January 22, 2010 22:52
Show Gist options
  • Save oliverbarnes/284257 to your computer and use it in GitHub Desktop.
Save oliverbarnes/284257 to your computer and use it in GitHub Desktop.
class Person < ActiveRecord::Base
attr_accessor :cell_area_code, :cell_number
before_save :merge_cellphone
private
def merge_cellphone
self.cellphone = "(#{cell_area_code}) #{cell_number}"
end
end
## in the view
<% form.inputs do %>
<%= form.input :name, :label => "Nome" %>
<li id="person_cell_number_input">
<label for="person_cell_number">Celular<abbr title="Obrigatório">*</abbr></label>
<%= form.text_field :cell_area_code, :size => 5 %> <%= form.text_field :cell_number, :size => 15 %>
</li>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment