RubyFlow The Ruby and Rails community linklog

×

The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

Making controller logic easier to test, by removing it from the controller

The gem can be found here: https://github.com/NullVoxPopuli/skinny_controllers

It’s inspired by trailblazer, but sticks more to how rails is laid out.

To use the default functionality, for each of your actions, you can just do:

render json: model

or however you want to render the response. model is a memoized method that looks up an operation and policy and applies whatever custom logic you want to implement.

Checkout the readme for details.


I’m using this gem in a production sass project with Ember as my frontend and ActiveModelSerializers for helping structure JSON, so support for skinny_controllers isn’t going away ever.


Hope you like it :-)

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in