Last active
November 9, 2015 15:53
-
-
Save kellishaver/06afba56295d6823e238 to your computer and use it in GitHub Desktop.
devise guest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>form action="/users" method="post"> | |
<input type="hidden" name="is_guest_account" value="true"> | |
<input type="submit" value="Try it!"> | |
</fprm> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Devise::Custom::RegistrationsController < Devise::RegistrationsController | |
def create | |
if params[:is_guest_account] | |
guest_token = rand(36**6).to_s(36) | |
guest_pass = rand(36**64).to_s(36) | |
params[:user] = { | |
email: "guest_#{guest_token}@yourdomain.com", | |
password: guest_pass, | |
password_confirmation: guest_pass | |
} | |
super | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment