which is influenced by Trailblazer, but less with some different opinions
here and there.
The main idea that it pulls out of trailblazer is operations and policies.
Operations are in `app/operations`
Policies are in `app/policies`
Operations control what data you are getting, and Policies control if you
are allowed to get it.
The goal is to have all the logic in ruby objects that don't require a
controller instance to run (i.e. avoiding put/get/post in your tests).
At the very minimum, you'd need
# and then in your action
render json: model
and the rest is implicit.
obviously, not everyone wants the same create / update / destroy
functionality, so that can all be configured:
here is an example of the `create` operation for the `EventsController`
class Create < SkinnyControllers::Operation::Base
return unless allowed?
# @model is used here, because the method `model` is memoized off
@model = model_class.new(model_params)
@model # or just `model`
`allowed?` is a special method that looks up the corresponding policy:
class EventPolicy < SkinnyControllers::Policy::Base
# for the Create operation for the EventsController is matched to create?
in the policy
# o / object here is the instance of the model trying to be created
def create?(o = object)
I'm using this in a big side project I've been working on for event
registration. (Rails API + Ember)
example of operation specs:
example of policy specs:
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to email@example.com.
To post to this group, send email to firstname.lastname@example.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e2760ca2-b7e2-4690-827f-2a4410196ab1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.