Lightrail 0.99.0: minimalist Rails 3 stack for JSON APIs

One of the great advancements of Rails 3 brought to the table was enough
modularity to let you build custom Rails stacks tuned to specific
needs. Out of the box Rails is tuned to be as inclusive as possible,
bringing you as many features as it possibly can. It’s modular enough
you
can remove what you want if you don’t need it, but by default ships with
everything on.

This inclusiveness lead to a backlash of minimalist frameworks, most
notably Sinatra. Sinatra tried to provide as little as possible while
still
being useful, and at the same time removed much of the Rails ceremony
from
the DSL it used for rendering responses.

Thanks to Rails 3, the framework is now modular enough you can boot a
barebones version of it from a single file:

Lightrail ships a Rails 3 barebones stack, but with some added niceties
for
apps that provide JSON APIs:

https://github.com/lightness/lightrail

It’s minimalist Rails 3 with enough Sinatraisms baked in I hope it can
win
over some of those people who think Rails is too bloated and use Sinatra
instead. That’s not to say Sinatra is bad, but I have seen apps built on
Sintra which have outgrown it, and for them, I think a Rails-based stack
would be a better choice.

For those of you who hated Rails 3’s stack traces, Lightrail ships with
minimal middleware and is tuned to eliminate many of the frustrations
which
give the impression Rails is a big bloated framework.

Lightrail is originally derived from the Rails 3 stack used for
applications with client-heavy SproutCore front-ends at Strobe (
http://strobecorp.com). Its principal authors are Jos Valim and Carl
Lerche.

Install the lightrail gem:

gem install lightrail

Like Rails, installing the lightrail gem will install a command line
utility called ‘lightrail’. This command is in fact identical to the
‘rails’ command, but tweaked for Lightrail defaults instead of Rails
defaults.

You can use ‘lightrail’ to create a new application skeleton just like
Rails:

lightrail new myapp

The skeleton application that Lightrail generates is identical to a
standard Rails application, with only these changes:

  • Gemfile pulls in lightrail instead of rails
  • application.rb pulls in lightrail instead of rails
  • ApplicationController descends from
    Lightrail::ActionController::Metal
    instead of ActionController::Base. ActionView is not used or
    installed.

Once you’ve created your application, run:

lightrail server

to launch a web server in the development environment (just like Rails!)

You can convert an existing Rails 3 application to a Lightrail
application
by retrofitting the changes mentioned above.

Wonderful, this seems to fit my needs very well!! Thank you for this
gem!

saji

On Sun, Mar 11, 2012 at 8:57 AM, Tony A. [email protected]
wrote:

It’s minimalist Rails 3 with enough Sinatraisms baked in I hope it can win
with client-heavy SproutCore front-ends at Strobe (http://strobecorp.com).
command, but tweaked for Lightrail defaults instead of Rails defaults.
application.rb pulls in lightrail instead of rails
by retrofitting the changes mentioned above.


Tony A.

Saji N Hameed,
ARC-ENV, Center for Advanced Information Science and Technology,
University of Aizu, Tsuruga, Ikki-machi,
Aizuwakamatsu-shi, Fukushima 965-8580,
Japan

Tel: +81242 37-2736
Fax:+81242 37-2760
email: [email protected]
url: http://www.u-aizu.ac.jp
bib: http://www.researcherid.com/rid/B-9188-2009

On Sun, Mar 11, 2012 at 7:57 AM, Tony A. [email protected]
wrote:

gem install lightrail

lightrail new myapp

can you tweak rails so you can just do something like,

rails new myapp --light

thanks for the light
kind regards -botp

Rails will have API only application support soon:

http://edgeguides.rubyonrails.org/api_app.html

Perhaps there will be some cross-pollination between Light Rail and
Rails’
own API only applications and eventually Lightrail will be irrelevant.

That said, Lightrail is ready to use now with minimalist defaults. It’s
a
Rails 3 stack we used successfully at Strobe which is written by Rails
Core
authors.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs