Dismiss
Announcing Stack Overflow Documentation

We started with Q&A. Technical documentation is next, and we need your help.

Whether you're a beginner or an experienced developer, you can contribute.

Sign up and start helping → Learn more about Documentation →

I am trying to figure out the best way to combine a first_name and last_name field in Ecto.

In rail's active record I can create an instance method like:

def name
  self.first_name + self.last_name
end

then when I create an active record instance I can use User.name. If I need to combine the first and last name or do some other logic to my Ecto model how would I go about doing that? This is a simple example and I could just concatenate it on the fly, but what if there was more complicated logic?

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.