Ruby on Trails
What is Ruby on Trails?
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.
Serverhandles requests and creates responses, nesting the main app within aRack::Builderinstance that contains middleware (e.g. a StackAssetsServer that serves stylesheets).Routeruses routes to direct requests to controllers.TrailsController::Basebuilds responses based on parameters and renders content usingERBviews, including partials.Sessionsets and reads cookies to persist data between requestsFlasha special type of information that lives for only one subsequent request (or just the current one, if usingFlash#now).
Technologies
- Ruby
- Rack
- ERB
- SQLite3
- Thor
- JSON