api_controller

Generator for controllers dedicated to custom APIs.

Usage

rails generate api_controller MODEL(plural, lowercase) [VERSION]

rails generate api_controller people 2

generates:

app/controllers/api/v2/person_api_controller.rb
test/functional/api/v2/person_api_controller.rb

To do

  • modularize test framework usage

  • add proper requirements to all files so that everything works outside of a rails project (and in different versions of rails)

  • make opinionated, robust api and test generation

  • test!

  • change the parameters for the command so that either the plural (people) or class name (Person) can be used.

  • use variable caching in generation methods (version)

  • shorten generator name

  • only make new routes if necessary

  • default generator should be ‘api’ (generates test and controller); possibly add other generators (test, controller, barebones, etc.)

  • properly insert routes

Contributing to api_controller

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet

  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it

  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright © 2011 Cody Frazer. See LICENSE.txt for further details.