We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Fix syntax highlighting
Small grammatical fix
Consistently use Ruby 1.9 hash syntax
FactoryGirl -> FactoryBot
Adding note that someone abstracted the work here.
create calls save
In the case session[:guest_user_id] is present but that user doesn't exists anymore in database(Can happen in dev environment) `guest_user` will return nil and nil.reload will give an exception.
Added testing instructions
Updated How To: Create a guest user (markdown)
fix small grammatical error for clarification
Rails still has the associations to the guest_user cached after calling 'logging_in'. If the User model has a 'dependent: :destroy' parameter the associations will be deleted even if the user is changed. Reloading the guest user before destroying makes sure rails pick up the changes.
rm unnecessary profanity
the guest user code has two bugs: 1. with the warden strategy, it's possible for the current_user to be the guest_user, thus we need to check whether guest_user_id is equal to current_user.id to prevent it from being destroyed. 2. there is a possibility that we are unnecessarily creating then destroying a guest user
Fix `rand` in code so the upper bound is 99 instead of 98
Finder in authentication strategy could raise when guest record doesn't exist
Adds in a method for authenticating the guest user
Wrapped guest_user function in begin block for rescue. Additionally signed in guest user in the guest user function
Changed :receive_guess to :receive_guest. Pretty sure that's a spelling error.
Lack of checking return value from save method. Caching of guest_user instead of fetching it every time.
saves session[:guest_user_id] on create_guest_user method, to avoid multiple user creations in same session
Added instruction to make method available to views
Use `||=` idiom to create a guest user.
Had an extra 'end' (copy-paste error)
Added some (commented out) logging_in example code. Made logging_in private.
change generated email address to 'example.com' per RFC2606