Settings Keys
All settings are stored in lean_cms_settings and accessed via LeanCms::Setting. Values are cached in SolidCache for one hour.
Reading and writing settings
# Read a setting with a fallback default
LeanCms::Setting.get('site_phone', '')
# Write a setting
LeanCms::Setting.set('site_phone', '(555) 123-4567')
# Check a boolean setting
LeanCms::Setting.enabled?('in_context_editing')
# Read without cache (for settings that must take effect immediately)
LeanCms::Setting.get_uncached('content_locked', 'false')
# JSON storage
LeanCms::Setting.get_json('business_hours', {})
LeanCms::Setting.set_json('business_hours', { hours: [...], note: '' })
CMS behavior settings
| Key | Default | Description |
|---|---|---|
in_context_editing |
"true" |
Show edit overlays for logged-in CMS users. Set to "false" to hide overlays without disabling auth. |
content_locked |
"false" |
Block all CMS write operations. Set automatically by the content sync workflow. |
content_locked_at |
— | ISO 8601 timestamp of when the lock was set. |
content_locked_reason |
— | Human-readable reason for the lock (optional). |
Toggle in-context editing
LeanCms::Setting.set('in_context_editing', 'false') # hide overlays
LeanCms::Setting.set('in_context_editing', 'true') # show overlays
Content locking
These are managed automatically by the sync rake tasks, but you can call them directly:
LeanCms::Setting.lock_content!("Deploying new structure")
LeanCms::Setting.unlock_content!
LeanCms::Setting.content_locked? # => true / false
LeanCms::Setting.content_lock_info # => { locked_at: "...", reason: "..." }
Site information settings
These power the LeanCms::Setting convenience methods and can be set from the Settings admin panel.
| Key | Convenience method | Description |
|---|---|---|
site_phone |
LeanCms::Setting.site_phone |
Business phone number |
site_email |
LeanCms::Setting.site_email |
Business email address |
site_address |
LeanCms::Setting.site_address |
JSON-encoded address object (street1, street2, city, state, zip) |
business_hours |
LeanCms::Setting.business_hours |
JSON-encoded hours array with optional note |
Using in views
<p><%= LeanCms::Setting.site_phone %></p>
<p><%= LeanCms::Setting.site_email %></p>
<%# Multi-line address %>
<address>
<%= simple_format LeanCms::Setting.site_address %>
</address>
<%# Single-line address %>
<p><%= LeanCms::Setting.site_address_single_line %></p>
Address data structure
site_address is stored as JSON and returns a hash:
LeanCms::Setting.site_address_data
# => { 'street1' => '123 Main St', 'street2' => '', 'city' => 'Portland',
# 'state' => 'OR', 'zip' => '97201' }
Business hours data structure
business_hours is stored as JSON:
LeanCms::Setting.business_hours
# => {
# 'hours' => [
# { 'days' => 'Mon–Fri', 'hours' => '8am–5pm' },
# { 'days' => 'Sat', 'hours' => '9am–2pm' }
# ],
# 'note' => 'Closed on major holidays'
# }
Mailer configuration
Lean CMS-sent emails (password reset, invitations, admin-triggered resets) use
the gem’s LeanCms::ApplicationMailer, which defaults the From: address to
the value of LeanCms.mailer_from:
# config/initializers/lean_cms.rb
LeanCms.configure do |config|
config.mailer_from = "noreply@acme.com"
end
Default: "noreply@example.com". You should override this for any
production deployment so emails don’t get flagged by recipient mail servers.
Adding custom settings
Any key can be stored and retrieved. Custom settings are immediately available after being set:
# Set a custom setting
LeanCms::Setting.set('announcement_banner', 'We are open for orders!')
LeanCms::Setting.set('show_announcement', 'true')
# Read in a view
<% if LeanCms::Setting.enabled?('show_announcement') %>
<div class="banner">
<%= LeanCms::Setting.get('announcement_banner') %>
</div>
<% end %>
Custom settings can be managed from the Settings admin panel once added — no code change required to update the value.