Summary:
I made set_refer_cookie a public method, allowed passing in a code, and overriding track_visit.
Description:
The reason for these changes are to provide more flexibility on when and how refer cookies are set.
For example, let's say you have an app where users can create public listings. When someone visits a user's listing, you want to set a cookie to "reward" the user if someone new signs up through their public listing.
With the existing Refer implementation, this requires ensuring that the public listings always have a ?ref=code parameter set. But with a more flexible set_refer_cookie method we can do something like this:
class ListingsController < ApplicationController
def show
@listing = Listing.find(params[:id])
# Set cookie
code = @listing.user.referral_codes.first.code
set_refer_cookie(code: code, track_visit: false)
end
end
Testing:
I haven't tested it yet 😅
Checklist:
[x] Code follows the project's coding standards
[ ] Tests have been added or updated to cover the changes
[ ] Documentation has been updated (if applicable)
Pull Request
Summary: I made
set_refer_cookie
a public method, allowed passing in acode
, and overridingtrack_visit
.Description: The reason for these changes are to provide more flexibility on when and how refer cookies are set.
For example, let's say you have an app where users can create public listings. When someone visits a user's listing, you want to set a cookie to "reward" the user if someone new signs up through their public listing.
With the existing Refer implementation, this requires ensuring that the public listings always have a
?ref=code
parameter set. But with a more flexibleset_refer_cookie
method we can do something like this:Testing: I haven't tested it yet 😅
Checklist:
Additional Notes:
If you approve of this change, I can add tests.