Rails tabler template

ยท 748 words ยท 4 minute read
Rails starter boilerplate that you can clone and build on top of

rails-tabler

Demo | Github

Goals ๐Ÿ”—

Users familiar with rails should be able to build with this boilerplate without requiring extensive introduction.

  • No DSL
  • Avoid complex frontend functionality
  • Simplicity over efficiency

Overview ๐Ÿ”—

Baked in foundational models ๐Ÿ”—

When developing a robust web application, it’s crucial to have a well-structured data model. This template includes multiple pre-built models that you can leverage to accelerate your project. Here are some of the key models you’ll find:

  • Users

    Your application’s user base is at its core. With the User model, you can efficiently manage user registration, profiles, and authentication.

  • Roles

    Roles play a pivotal role in defining user permissions and responsibilities within your application. Whether you have admins, moderators, or regular users, role management simplifies access control.

  • Plans

    If your application offers various subscription plans with differing features and pricing, the Plans model is your go-to. It can store plan details and help users choose the subscription that suits them best.

  • Subscriptions

    To handle user subscriptions, the Subscriptions model tracks subscription deatils, plan information, and renewal dates, making subscription management a breeze.

User authentication & authorization ๐Ÿ”—

  • Authentication through Devise

    Devise, a widely-used authentication gem for Rails, offers ready-made components for user registration, login, and password recovery, ensuring a secure user experience.

  • OmniAuth for Third-Party Authentication

    Take your authentication capabilities to the next level by integrating OmniAuth. This allows users to log in using their social media or other online accounts, enhancing user convenience.

  • Authorization with Pundit

    Pundit simplifies role-based authorization in Rails. Define policies to control access to specific resources or actions based on user roles, strengthening your application’s security.

Background worker & scheduler ๐Ÿ”—

Efficiently handle background tasks and job scheduling with the built-in support for Sidekiq and Sidekiq Scheduler. These tools ensure that resource-intensive tasks don’t hinder your application’s performance, enhancing overall user experience.

Role management ๐Ÿ”—

Effective role management is critical for applications with diverse user privileges. Supports standard roles available across spaces while also allowing you to create custom roles specific to each space. Fine-grained permissions per role ensure precise control over user access.

Multiple user groups support ๐Ÿ”—

Introduces the concept of a “Space” model to represent user groups, which can be teams, organizations, or any other namespace. You have the flexibility to enable or disable multi-space mode, making it suitable for various use cases:

  • Example use case for turning on multi-space mode: Saas applications where multiple groups require separate spaces.
  • Example use case for turning off multi-space mode: Internal organizational tools where only admins can invite users and create spaces.

Pre built UI layouts ๐Ÿ”—

A well-designed user interface is key to providing an excellent user experience. The Starter Kit integrates high-quality UI elements and layouts from Tabler, allowing you to create a professional and polished appearance with ease.

Development focussed ๐Ÿ”—

  • Annotate - Annotate Rails classes with schema and routes information for improved code documentation.
  • Brakeman - Static analysis security vulnerability scanner to identify potential security risks in your code.
  • Byebug - Straightforward debugger for troubleshooting issues during development
  • Dotenv - Simplify environment variable management by loading them from a .env file.

Setup ๐Ÿ”—

requires postgres and redis to run on local

brew install postgresql@12 redis

clone the repo

git clone https://github.com/tarunvelli/rails-tabler-starter.git

use asdf to install required dependencies, or setup the dependencies .tool-versions in another way

asdf install

setup and run dev server

bin/setup
bin/dev

Mark a user as admin from console to view admin features in the user dropdown

bundle exec rails c
> User.first.update(admin: true)

AppSettings ๐Ÿ”—

Toggle app settigns at /setup/edit

  • AppSettings.interface_layout

    • Layout of app
    • values [“VERTICAL”, “HORIZONTAL”, “OVERLAP”, “CONDENSED”]
  • AppSettings.interface_mode

    • Light/Dark mode of app
    • “SYSTEM” picks the mode from system preferences
    • Values [“LIGHT”, “DARK”, “SYSTEM”]
  • AppSettings.interface_theme

    • Color theme of app
    • Values [“DEFAULT”, “COOL”]
  • AppSettings.login_layout one of

    • Layout of login screens
    • Values [“DEFAULT”, “ILLUSTRATION”, “COVER”]
  • AppSettings.multi_space_mode

    • When true allows users to sign up and create spaces
    • When false allows only admin to invite users and create spaces
    • Values [true, false]
  • AppSettings.show_landing_page

    • When true root path renders landing page
    • When false root path redirects to sign in page
    • Values [true, false]

Sample settings for different use cases ๐Ÿ”—

Here are sample configurations for two different application types:

  • Saas App
AppSettings.interface_layout = 'HORIZONTAL'
AppSettings.interface_mode = 'LIGHT'
AppSettings.interface_theme = 'DEFAULT'
AppSettings.login_layout = 'ILLUSTRATION'
AppSettings.multi_space_mode = true
AppSettings.show_landing_page = true
  • Internal App
AppSettings.interface_layout = 'CONDENSED'
AppSettings.interface_mode = 'LIGHT'
AppSettings.interface_theme = 'DEFAULT'
AppSettings.login_layout = 'DEFAULT'
AppSettings.multi_space_mode = false
AppSettings.show_landing_page = false

Deployment ๐Ÿ”—

Happy coding!