Ruby on Trails

What is Ruby on Trails?

View the Sample App Live

Trails Sample App Repository to see how to use Trails

Trails is a lightweight MVC framework built in Ruby by Will McMeans. It is similar in functionality to Ruby on Rails, but flavored the way I like it. It features a custom ORM called Dynamic Archive (doesn't that sound more exciting than Active Record?) and everything else you need to build a simple web app. We're not riding rails...we're hiking trails!

How to Get Started

Install the Trails Gem

gem install trails-mvc

Create Your First App

trails new <name> — begins a new Trails project

Start the Server

trails server [--host] [--port] — starts the Trails server; default host: localhost, default port: 3000

Generate Models and Controllers

trails generate model <model_name> — creates a new model file in app/models and a new migration in db/migrations

trails generate controller <controller_name> — creates a new controller file in app/controllers and a corresponding view folder in app/views

trails generate migration <migration_name> — creates a blank migration file in db/migrations (but no model file)

Change the Database

trails db reset — clears the database, runs all migrations, and re-seeds

trails db migrate — runs all pending database migrations

trails db seed — seeds the database

Add Routes

Follow the example in config/routes.rb

Add CSS and JavaScript

It's recommended to add styling to public/assets/application.css and any JavaScript to public/assets/application.js. You may also include other scripts and stylesheets in your views as long as you store them in public/assets.

Not Sure What to do Next?

Check out the Trails Sample App Repository to get a better idea of what you can do with Ruby on Trails

Features

  • Dynamic Archive (Custom ORM) creates rich relationships between objects.
  • Server handles requests and creates responses, nesting the main app within a Rack::Builder instance that contains middleware (e.g. a StackAssetsServer that serves stylesheets).
  • Router uses routes to direct requests to controllers.
  • TrailsController::Base builds responses based on parameters and renders content using ERB views, including partials.
  • Session sets and reads cookies to persist data between requests
  • Flash a special type of information that lives for only one subsequent request (or just the current one, if using Flash#now).

Technologies

  • Ruby
  • Rack
  • ERB
  • SQLite3
  • Thor
  • JSON