Tila
Most Rails projects contain a lot of controllers that are quite repetitive, because most controllers essentially what is needed to get a simple CRUD interface. This project contains components that can be used to build the controller of this simple CRUD interface.
Because Tila favors composition over inheritance, is allows for a flexibility that most other projects in this space don't have. If you only want to use a part of Tila, that works perfectly fine.
Components
- Actionable: Provides an
action
helper so we can simply find out which action is called and contains a list of actions that are operated on collection and which actions are actions that save the model instance. It also provides simple helpers to find out if the current action is in one of the lists. - Modelable: Provides an
model
helper so we can access the model that the controller is for, and a few helpers to access model name. - Messages: Provide a simple helper for generating message strings from I18n. Requires Modelable.
- Objects: Provides a simple accessor for
@object
and@objects
. The ResourceLoaders component registers the loaded resources here. - Params: Provides a way to update the attributes of the object and simple starting point for filtering out the permitted resource params. Requires Modelable, Objects.
- SaveDestroy: Provides the
save_object
anddestroy_object
methods. Requires Objects. - FormHandler: Provides methods to handle the submit of forms and the
destroy. Requires Messages, Objects, SaveDestroy. You need to define a
location_after_save
and alocation_after_destroy
method, if you want to use this module in isolation. The Resourceful component defines these methods for you. - ResourceLoaders: Provides methods for loading the resources. Requires Modelable and Objects.
- ResourcefulUrls: Generates the URLs to the controller. Requires Modelable.
- Resourceful: Implements the actual controller actions, registers the before_action to load the resources. This is the part that you want to include when you want to enjoy the full glory of Tila. Requires Actionable, Params, FormHandler, ResourceLoaders and ResourcefulUrls.