0.02
No commit activity in last 3 years
No release in over 3 years
Transit format helpers for Rails. See Cognitect's transit-format for more info.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6

Runtime

>= 0.8.602, ~> 0.8
 Project Readme

transit-rails

Travis status

Use transit format in your Rails application, with minimal friction.

Works wherever transit-ruby does.

Installation

Add this line to your application's Gemfile:

gem 'transit-rails'

And then execute:

$ bundle

Or install it yourself as:

$ gem install transit-rails

Usage

In a Rails controller:

def index
  @posts = Post.all
  respond_to do |format|
    format.html
    format.transit { render transit: @posts }
  end
end

The renderer can take a verbose flag, which when true will output transit in the json-verbose format.

def index
  @posts = Post.all
  render transit: @posts, verbose: true
end

You can supply any custom handlers using the handlers option.

def index
  @person = Person.new
  render transit: @person, handlers: { Person => PersonHandler.new }
end

Read more about custom handlers on the transit-ruby README.

Contributing

  1. Fork it ( https://github.com/jgdavey/transit-rails/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request