This guide provides real-world examples of using Fluxbit generators to create different types of applications and features.
E-commerce Product Management
Create a complete product management system for an online store.
Basic Product Scaffold
rails generate fluxbit:scaffold Product \
name:string \
description:text \
price:decimal \
stock:integer \
category:string \
featured:boolean \
published:boolean \
--ui=modal \
--paginator
Generated Features:
- Product listing with search and filters
- Modal forms for quick editing
- Bulk operations for managing inventory
- Featured product toggles
- Price and stock filtering
Advanced Product with Images
rails generate fluxbit:scaffold Product \
name:string \
description:text \
price:decimal \
stock:integer \
category:string \
brand:string \
weight:decimal \
dimensions:string \
featured:boolean \
published:boolean \
created_at:datetime \
--ui=drawer \
--paginator
Customization after generation:
# Add image upload to the form
# app/views/products/_form.html.erb
<%= fx_dropzone(:images, form: f, multiple: true, accept: "image/*") %>
# Add category filtering
# app/controllers/products_controller.rb
def index
# ... existing code ...
@category = params[:category]
@products = @products.where(category: @category) if @category.present?
@categories = policy_scope(Product).distinct.pluck(:category).compact.sort
end
Blog Management System
Create a full-featured blog management interface.
Blog Posts
rails generate fluxbit:scaffold Post \
title:string \
content:text \
excerpt:string \
author:string \
status:string \
published_at:datetime \
featured:boolean \
tags:text \
--ui=none \
--paginator
Why --ui=none: Blog posts often require rich text editors and complex layouts, making full-page forms more suitable.
Categories Management
rails generate fluxbit:scaffold Category \
name:string \
description:text \
color:string \
posts_count:integer \
--ui=modal \
--paginator
Comments (with Drawer UI)
rails generate fluxbit:scaffold Comment \
post:references \
author_name:string \
author_email:string \
content:text \
status:string \
created_at:datetime \
--ui=drawer \
--paginator
User Management Dashboard
Create an admin interface for user management.
User Accounts
rails generate fluxbit:scaffold User \
name:string \
email:string \
role:string \
status:string \
last_login_at:datetime \
created_at:datetime \
email_verified:boolean \
--ui=drawer \
--paginator \
--pundit
Generated Policy (app/policies/user_policy.rb):
class UserPolicy < ApplicationPolicy
def index?
user.admin? || user.manager?
end
def show?
user.admin? || user.manager? || record == user
end
def create?
user.admin?
end
def update?
user.admin? || (user.manager? && !record.admin?) || record == user
end
def destroy?
user.admin? && record != user
end
end
User Sessions/Activity
rails generate fluxbit:scaffold UserSession \
user:references \
ip_address:string \
user_agent:string \
started_at:datetime \
ended_at:datetime \
active:boolean \
--ui=none \
--no-pundit
Project Management Tool
Create a project management interface.
Projects
rails generate fluxbit:scaffold Project \
name:string \
description:text \
status:string \
priority:string \
start_date:date \
end_date:date \
budget:decimal \
progress:integer \
manager:string \
--ui=modal \
--paginator
Tasks
rails generate fluxbit:scaffold Task \
project:references \
title:string \
description:text \
status:string \
priority:string \
assigned_to:string \
due_date:date \
estimated_hours:decimal \
completed:boolean \
--ui=drawer \
--paginator
Custom Task Form Enhancement:
<!-- app/views/tasks/_form.html.erb -->
<%= form_with model: [@project, task], local: true do |f| %>
<%= fx_text_field(:title, form: f, required: true) %>
<%= fx_text_area(:description, form: f, rows: 3) %>
<div class="grid grid-cols-2 gap-4">
<%= fx_select(:status,
options_for_select([
['To Do', 'todo'],
['In Progress', 'in_progress'],
['Done', 'done']
]),
form: f) %>
<%= fx_select(:priority,
options_for_select([
['Low', 'low'],
['Medium', 'medium'],
['High', 'high']
]),
form: f) %>
</div>
<%= fx_date_field(:due_date, form: f) %>
<%= fx_number_field(:estimated_hours, form: f, step: 0.5) %>
<%= fx_toggle(:completed, form: f) %>
<% end %>
Inventory Management
Create a warehouse inventory system.
Products/Items
rails generate fluxbit:scaffold InventoryItem \
sku:string \
name:string \
description:text \
category:string \
current_stock:integer \
minimum_stock:integer \
maximum_stock:integer \
unit_cost:decimal \
selling_price:decimal \
supplier:string \
location:string \
--ui=modal \
--paginator
Stock Movements
rails generate fluxbit:scaffold StockMovement \
inventory_item:references \
movement_type:string \
quantity:integer \
reason:string \
notes:text \
user:string \
created_at:datetime \
--ui=drawer \
--no-turbo
Why --no-turbo: Stock movements might require page refreshes to ensure data consistency.
Customer Support System
Create a support ticket system.
Support Tickets
rails generate fluxbit:scaffold SupportTicket \
customer_name:string \
customer_email:string \
subject:string \
description:text \
priority:string \
status:string \
assigned_to:string \
created_at:datetime \
resolved_at:datetime \
--ui=none \
--paginator
Knowledge Base Articles
rails generate fluxbit:scaffold KnowledgeArticle \
title:string \
content:text \
category:string \
tags:string \
published:boolean \
views_count:integer \
helpful_count:integer \
author:string \
--ui=drawer \
--paginator
Event Management
Create an event planning and management system.
Events
rails generate fluxbit:scaffold Event \
name:string \
description:text \
start_datetime:datetime \
end_datetime:datetime \
location:string \
max_capacity:integer \
current_registrations:integer \
price:decimal \
status:string \
featured:boolean \
--ui=modal \
--paginator
Event Registrations
rails generate fluxbit:scaffold EventRegistration \
event:references \
attendee_name:string \
attendee_email:string \
phone:string \
special_requirements:text \
status:string \
payment_status:string \
registered_at:datetime \
--ui=drawer \
--paginator
Multi-tenant Application
Create a multi-tenant SaaS application structure.
Organizations (Tenants)
rails generate fluxbit:scaffold Organization \
name:string \
subdomain:string \
plan:string \
status:string \
users_count:integer \
created_at:datetime \
subscription_ends_at:datetime \
--ui=modal \
--paginator \
--pundit
Organization Users
rails generate fluxbit:scaffold OrganizationUser \
organization:references \
user:references \
role:string \
status:string \
invited_at:datetime \
joined_at:datetime \
--ui=drawer \
--paginator
Advanced Customizations
Custom Bulk Actions
Add custom bulk operations to generated controllers:
# app/controllers/products_controller.rb
def bulk_feature
@products = policy_scope(Product).where(id: params[:selected_ids])
authorize Product, :bulk_feature?
@products.update_all(featured: true)
respond_to do |format|
format.turbo_stream do
flash[:notice] = "#{@products.count} products featured successfully"
render 'bulk_feature'
end
format.html { redirect_to products_path, notice: "Products featured successfully" }
end
end
Custom Search Implementation
Enhance search beyond basic LIKE queries:
# app/controllers/products_controller.rb
def index
# ... existing code ...
if @q.present?
@products = @products.where(
"name ILIKE :q OR description ILIKE :q OR category ILIKE :q",
q: "%#{@q}%"
)
end
# Full-text search (if using PostgreSQL)
if Rails.env.production? && @q.present?
@products = @products.where(
"to_tsvector('english', name || ' ' || description) @@ plainto_tsquery(?)",
@q
)
end
end
Custom Form Validations
Add client-side validations to generated forms:
<!-- app/views/products/_form.html.erb -->
<%= fx_text_field(:name,
form: f,
required: true,
data: {
"validation-required": true,
"validation-message": "Product name is required"
}) %>
<%= fx_number_field(:price,
form: f,
step: 0.01,
min: 0,
data: {
"validation-min": 0,
"validation-message": "Price must be greater than 0"
}) %>
Custom Turbo Stream Actions
Create custom Turbo Stream responses:
<!-- app/views/products/feature.turbo_stream.erb -->
<%= turbo_stream.replace "product_#{@product.id}" do %>
<%= render 'products', product: @product %>
<% end %>
<%= turbo_stream.update "flash" do %>
<%= render 'shared/flash' %>
<% end %>
<%= turbo_stream.update "featured_count" do %>
<%= Product.where(featured: true).count %> featured products
<% end %>
Best Practices from Examples
- Choose UI Based on Complexity
- Simple forms → Modal
- Complex forms → Drawer
- Multi-step workflows → None (separate pages)
- Use Appropriate Pagination
- Small datasets → Pagy (fastest)
- Need advanced features → Kaminari
- Legacy projects → WillPaginate
- Security First
- Always use Pundit in production
- Implement proper authorization policies
- Validate generated permissions
- Customize Incrementally
- Start with generated code
- Add features one at a time
- Test after each modification
- Follow Rails Conventions
- Use proper associations
- Follow RESTful routes
- Implement proper error handling