Skip to content

Adds Protector support to SimpleForm associations

License

Notifications You must be signed in to change notification settings

toxix/protector-simple_form

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Adds Protector support to SimpleForm associations

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%