Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

checkboxes

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

checkboxes

  • 0.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

h2. Introduction

This gem will help you to handle has_many :through associations when you need to add/remove these ones with checkboxes. If you think about this type of situation you do the same steps for each association you have to handle with checkboxes. I exctracted this gem from a project where I had to handle about ten associations with checkboxes.

h2. How to use it

The best way to describe throughcheckboxes is to show some code:

In your model:

class User < ActiveRecord::Base
    has_many :groups,:through=>:user_groups
    has_many :user_groups
    # add your associations
    checkboxes_for :groups
end

class Group < ActiveRecord::Base
    attr_accessible :name

    def to_s
        name
    end
end

class UserGroup < ActiveRecord::Base
  belongs_to :user
  belongs_to :group
end

In your view:

<%= form_for @user do |f| %>
  <%= f.error_messages %>
  <%= f.checkboxes_for :groups  %>
  

<%= f.submit %>

<% end %>

and that's all. Now, when you submit your form you get the has_many :through association updated.

h2. Roadmap

  • improve documentation
  • write options for helper
  • write more helpers

h2. Copyright

This program is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See http://sam.zoy.org/wtfpl/COPYING for more details.

FAQs

Package last updated on 10 Sep 2011

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc