I’m trying to calculate the values of a column for given user. I have a column in my “joblist” table that is named “jobprice” and I would like to calculate the total of the “jobprice” column value for current_user. I’ve tried few ideas I’ve had but they didn’t work. I’ve gotten everything related already. Just need to figure out how to locate all user_id of current_user for “joblist” then take “jobprice” column value and sum up the total.
Any suggestions?
Try using
sum():This assumes you have declared a
has_many :joblistsassociation in yourUsermodel.