rpheath / restful_controller
- Source
- Commits
- Network (0)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Tree:
259e52b
rpheath (author)
Tue Mar 31 08:16:14 -0700 2009
restful_controller / README.textile
RestfulController
This is a very bare bones abstraction of the RESTful actions for a Rails resource controller. Nothing fancy. Supports pagination (for the index action, mainly) and custom Models (that don’t match the typical pattern – think of a SignupsController using a User model).
class ArticlesController < ApplicationController
restful_controller :model => Post, :pagination => true
end
Notes:
- by default the model will be the singularized version of the controller (ArticlesController => Article)
- automatically sets the expected instance variable for your views depending on the action being rendered. For articles example, the “show” action would setup an
@articlevariable, while the “index” action would setup an@articlesvariable, as you’d expect) - “supports pagination” means a #paginated(params[:page]) method will be called on your model (you may need to add that)
Nothing New
I’m aware that there are several solutions to this problem, but I didn’t want/need all of the features from that of resource_controller and friends. This plugin is very straight-forward and is primarily used for a few applications at work.
License
Copyright © 2009 Ryan Heath, released under the MIT license
