Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
📗 Use roar
representers with respond_with
in a way that you can use easily multiple representers for the same model and for the same controller but without being mandatory.
It contains the bare minimum to easily render roar representers as responses in Rails. It is a much simpler gem than roar-rails
. But it also supports MongoID.
I'm ensuring that it renders well for JSON but I have not checked it for XML.
Another limitation is that I've only made it work for class representers and not for module representers.
⚠️ The main branch is used for development. It is not a stable branch for usage. Please, use a release instead. Preferably, the latest.
Add this line to your application's Gemfile:
gem 'roar_responder'
And then execute:
bundle install
This gem requires to be used inside Rails alongside the gems roar and responders.
Include the concern (module) in the controller(s) you want with this line:
include ::RoarResponder::ControllerRespondable
If you want to use this gem inside a Rails::Engine
, require the gem by adding the following line in lib/{YOUR_ENGINE}/engine.rb
.
require 'roar_responder'
There are 3 possible ways to render the representer. They are the following, by order of what takes first in case that multiple are defined.
respond_with entity, representer_class: EntityRepresenter
.self.represents = { entity: EntityRepresenter, collection: CollectionRepresenter }
.app/representers
with the file name of model_name
with _representer.rb
. If this file does not exist, it follows the default serialization of the entity/object itself.You can render any object that responds to to_model
and model_name
. This works for any entity and collection of ActiveRecord, Mongoid, and other bare ruby objects that use ActiveModel features.
I usually test like this:
docker-compose up -d
cd test/dummy/ && ./bin/setup && cd ../..
bundle exec rake test
FAQs
Unknown package
We found that roar_responder demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.