
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Curtains provides simple model decorators for Rails 4.
Add this line to your application's Gemfile
:
gem "curtains"
And then execute:
$ bundle
Or install it yourself as:
$ gem install curtains
In either controllers or views you may call decorate
to wrap a model in a decorator. The name of the decorator class is inferred from the name of the model, so for example, the Address
model will be wrapped with AddressDecorator
.
# app/views/addresses/show.html.erb
<%= decorate(@address).formatted_address_tag %>
The decorate
helper also supports enumerable collections and will return an array of decorated objects:
# app/views/addresses/index.html.erb
<%= decorate(@addresses).each do |address| %>
<%= address.formatted_address_tag %>
<% end %>
Additionally, the decorate
helper yields its result to a block if provided:
# app/views/addresses/show.html.erb
<%= decorate(@address) do |address| %>
<div class="name">
<%= address.formatted_name %>
</div>
<%= address.formatted_address_tag %>
<% end %>
These decorators should be placed in the app/decorators
folder and should inherit from Curtains::Decorator
. For example:
# app/decorators/address_decorator.rb
class AddressDecorator < Curtains::Decorator
def formatted_address_tag
content_tag :address, address.lines.join("<br/>").html_safe
end
def formatted_name
return "N/A" if name.blank?
name
end
end
Call decorate_resources
in your controller to add automatic decorating to the resource
, build_resource
and collection
methods provided by Inherited Resources:
# app/controllers/address_controller.rb
class AddressesController < InheritedResources::Base
decorate_resources
end
# app/views/addresses/show.html.erb
<%= resource.formatted_address_tag %>
Handcrafted by Patrick Hogan [github]
Released under the MIT License.
FAQs
Unknown package
We found that curtains 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
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.