devise-rownd. This gem is an implementation of a custom strategy for the
popular Devise framework. It works in
tandem with the Rownd Hub, a javascript snippet embedded in your website. With
this gem installed, Rownd handles all aspects of user authentication and gives
you the tools to customize the user experience on your site.
Installation
Add this line to your application’sGemfile:
Mount the Engine
Add this to yourconfig/routes.rb file
Rownd Hub
Follow these instructions to install the Rownd Hub. You’ll want to ensure it runs on every page of your application, so be sure to add it as a common in your Rails JS packs. Here’s the easiest way to do that:- 
Create a new file in your JS packs directory called rownd.jsand paste the JS snippet that you got from the instructions listed above.
- 
- Add the following API callbacks to your Javascript:
 
The path prefix 
/api/auth/rownd must match the Devise::Rownd::Engine mount
path that you specified in your Rails routes- Finally, include the Javascript pack in your application layout.
<%= show_rownd_signin_if_required %> This renders the Rownd sign-in modal to
prompt the user for authentication when your app explicitly requires it in a
controller
<%= javascript_pack_tag 'rownd', 'data-turbolinks-track': 'reload' %> Tells
Rails to include the rownd Javascript pack. We also tell Turbolinks to include
the script on page reloads
Usage
For this to work, you need to define these key environment variables:- 
ROWND_APP_KEY- Your Rownd application key
- 
ROWND_APP_SECRET- Your Rownd application secret
Users
This gem provides a new Devise module named:rownd_authenticatable. In your
user model, you can tell Devise to use it like this:
config/routes.rb file, add the following:
Require Authentication
You can require authentication on a controller’s actions the same way you would for any Devise strategies.Customizing the page using the current_user
In any of your controllers, views, or helpers, you have access to the currently
authenticated user via the current_user variable. You can use it to customize
your page content like this:
current_user object has all of the fields specified in your Rownd
application’s schema. If the user doesn’t have a value for a particular field,
it will be nil
Extending the current_user model
You can extend the current_user object by modifying the Devise::Rownd::User
class. This can be very helpful if you want to have additional functions that
aggregate data across multiple fields, or perform some logic and return the
result.
For instance, you might want a function called admin? that will return if the
current user has an 'admin' role. To extend the current_user object, add a
new initializer in config/initializers called devise_rownd.rb. In there you
can modify the Devise::Rownd::User like this:
current_user.admin? and
current_user.display_name