I start to learn ruby on rails and I want to temporary add an attribute to a model so I added the accessor to my model :
@depenses = Depense.where(user_id: @user.id)
@depenses.each do |d|
d.dettes = "value"
render json: @depenses
render :json only adds the permanent attributes. You can add the temporary one as well this way:
render json: @depenses, methods: :dettes