SimpleForm Protector
Adds Protector support to SimpleForm associations.
Installation
Add this line to your application's Gemfile:
gem "protector-simple_form"
And then run the following command to install it:
bundle
Usage
Associations
SimpleForm does a great job at dealing with associations (f.association
helper) but when used in conjunction with Protector, it will not protect the collection used unless you specify it by hand using the :collection
option.
This gem will protect the collections that are automatically generated by SimpleForm using the same subject as the object the association belongs to.
In the event where you'd rather not have the automatically generated collection protected, you can set the :protect
option to false
.
<%= simple_form_for @user do |f| %>
<%= f.association :company, protect: false %> # Association scope: `Company.all`
<%= f.association :roles %> # Association scope: `Role.restrict!(@user.protector_subject)`
<% end %>
License
Copyright 2013 Deversus Software Inc. It is free software, and may be redistributed under the terms of MIT license.