Skip to content
A modern, responsive admin framework for Ruby on Rails
Ruby CSS HTML JavaScript
Branch: master
Clone or download

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app Don't use table helper to render resource index table May 25, 2020
bin Initial gem creation Jul 28, 2016
config add german translations Jan 5, 2020
frontend Implement preliminary support for AJAX pagination May 22, 2020
gemfiles Fix test suite Oct 29, 2019
lib Use unscoped singular admin name for form params key May 27, 2020
sandbox Fix test suite Oct 29, 2019
spec Use unscoped singular admin name for form params key May 27, 2020
.babelrc Implement new asset build process with updated asset dependencies Sep 20, 2019
.browserslistrc Implement new asset build process with updated asset dependencies Sep 20, 2019
.gitattributes Ignore diffs on bundled assets Sep 20, 2019
.gitignore Implement new asset build process with updated asset dependencies Sep 20, 2019
.rspec Initial gem creation Jul 28, 2016
.travis.yml Don't explicitly exclude Rails 4.2 Gemfile from Travis config Mar 4, 2020
Gemfile Remove explicit dependency on simplecov Feb 24, 2020
Guardfile Add basic Guard configuration May 31, 2019
LICENSE Initial gem creation Jul 28, 2016
README.md Clarify first admin resource creation in README Apr 30, 2020
Rakefile Initial gem creation Jul 28, 2016
package.json Update JS pipeline dependencies May 15, 2020
trestle.gemspec Update development dependencies Mar 2, 2020
webpack.config.js Switch back to cssnano using normalizePositions workaround Sep 20, 2019
yarn.lock Update JS pipeline dependencies May 22, 2020

README.md

Trestle Logo

Trestle

RubyGem Travis Coveralls Code Climate

Demo Site | Demo Source Code

A modern, responsive admin framework for Ruby on Rails

Getting Started

To start using Trestle, first add it to your application's Gemfile:

gem 'trestle'

Run bundle install, and then run the install generator to create the initial configuration file and customization hooks:

$ rails generate trestle:install

Then create your first admin resource (assuming you have an existing Article model):

$ rails generate trestle:resource Article

After restarting your Rails server, visit http://localhost:3000/admin to view your newly created admin. You will find the admin definition in app/admin/articles_admin.rb ready to customize.

Example

Trestle.resource(:posts) do
  # Add a link to this admin in the main navigation
  menu do
    group :blog_management, priority: :first do
      item :posts, icon: "fa fa-file-text-o"
    end
  end

  # Define custom scopes for the index view
  scopes do
    scope :all, default: true
    scope :published
    scope :drafts, -> { Post.unpublished }
  end

  # Define the index view table listing
  table do
    column :title, link: true
    column :author, ->(post) { post.author.name }
    column :published, align: :center do |post|
      status_tag(icon("fa fa-check"), :success) if post.published?
    end
    column :updated_at, header: "Last Updated", align: :center
    actions
  end

  # Define the form structure for the new & edit actions
  form do
    # Organize fields into tabs and sidebars
    tab :post do
      text_field :title

      # Define custom form fields for easy re-use
      editor :body
    end

    tab :metadata do
      # Layout fields based on a 12-column grid
      row do
        col(sm: 6) { select :author, User.all }
        col(sm: 6) { tag_select :tags }
      end
    end

    sidebar do
      # Render a custom partial: app/views/admin/posts/_sidebar.html.erb
      render "sidebar"
    end
  end
end

Plugins

The following plugins are currently available:

Name Description Links
trestle-auth User authentication plugin GitHub | RubyGems
trestle-search Search plugin GitHub | RubyGems
trestle-tinymce TinyMCE (WYSIWYG editor) integration GitHub | RubyGems
trestle-simplemde SimpleMDE (Markdown editor) integration GitHub | RubyGems
trestle-sidekiq Sidekiq integration GitHub | RubyGems
trestle-active_storage Active Storage integration GitHub | RubyGems
trestle-mobility Mobility integration GitHub | RubyGems
trestle-omniauth OmniAuth authentication plugin GitHub | RubyGems
trestle-auth-otp 2FA/OTP user authentication GitHub | RubyGems

License

The gem is available as open source under the terms of the LGPLv3 License.

You can’t perform that action at this time.