Skip to content

Instantly share code, notes, and snippets.

@kellishaver
Last active November 9, 2015 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kellishaver/06afba56295d6823e238 to your computer and use it in GitHub Desktop.
Save kellishaver/06afba56295d6823e238 to your computer and use it in GitHub Desktop.
devise guest
>form action="/users" method="post">
<input type="hidden" name="is_guest_account" value="true">
<input type="submit" value="Try it!">
</fprm>
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