I want to create a model attribute that looks exactly like a db field
but is
infact the result of a model function.
Example
I have a user with name and surname.
I want to be able to do @user.fullname which will then call a function
that
returns “name surname” as the full name, and I would like to be able to
pass
“name fullname” and have it broken into the seperate fields before
saving to
the db, in otherwords I would like it to function exacly asif there is a
fullname field.
I know this can be done, I just dont know where to start looking for
this.
“name fullname” and have it broken into the seperate fields before saving to
the db, in otherwords I would like it to function exacly asif there is a
fullname field.
I know this can be done, I just dont know where to start looking for this.
thanks a lot. I am going to be doing a fair amount of those. so
basically
you write 2 functions, one looks like a setter because of the “=” sign
at
the end…