I have a user model with :email
and :user_name
, I want to auto initialize :user_name
with part of :email
.
class User
include Mongoid::Document
field :email
field :user_name
end
I use simple_form to create the user.
How can I initialize :user_name
based on :email
?