I’m rails noob, and have been confused about sending params from controller to model. Say, my model has fields user_id_from and user_id_to, but to controller they came as to and from (for client-side simplify).
So in my controller I should modify fields for model with such ugly code:
UserRelationship.crate(:to => params[:user_id_to], :from => params[:user_id_from])
OR
this modification could be done some other way?
Usually, the easiest thing to do is change the controller or form to send them in as params[:user_id_to] and params[:user_id_from] if possible.
But another way to make it easier could be to use alias_attribute
The longhand way to do this is also pretty simple: