The easiest way of doing this is to set those checkboxes up to become an array.
HTML:
<input type="checkbox" name="tag_ids[]" value="1" />
<input type="checkbox" name="tag_ids[]" value="2" />
<input type="checkbox" name="tag_ids[]" value="3" />
Controller:
tag_ids = params[:tag_ids]
(Of course, you’d probably be using form_for
-based helpers in the view, and therefore mass-assigning the tag IDs. This is just the most generic example.)
Related Contents:
- What is the easiest way to duplicate an activerecord record?
- Rails Root directory path?
- What does “WARN Could not determine content-length of response body.” mean and how to I get rid of it?
- Add a CSS class to
- Ruby: Is there an opposite of include? for Ruby Arrays?
- Ruby on Rails and Rake problems: uninitialized constant Rake::DSL
- Removing all empty elements from a hash / YAML?
- Why is using the rails default_scope often recommend against?
- Rails: How to change the text on the submit button in a Rails Form
- RSpec: What is the difference between let and a before block?
- How to run rails s -p80 on 80 port?
- Rails number_field alternative for decimal values
- Setting Devise Login to be root page
- Getting the warning “Insecure world writable dir /home/chance ” in PATH, mode 040777 for rails and gem
- How does Rails ActiveRecord chain “where” clauses without multiple queries?
- Is devise’s token_authenticatable secure?
- To use self. or not.. in Rails
- Ruby on Rails will_paginate an array
- TZInfo::DataSourceNotFound error starting Rails v4.1.0 server on Windows
- Parsing string to add to URL-encoded URL
- rails server bin/rails:6: warning: already initialized constant APP_PATH error
- Alias for column names in Rails
- What is the use of secret_key_base in rails 4
- Send email from rails console
- How to stop a Daemon Server in Rails?
- Failed to build gem native extension — Rails install
- How can I count the number of records that have a unique value in a particular field in ROR?
- How to “soft delete” user with Devise
- redirect_to using POST in rails
- Where can I find options for “rails new” command?
- ActiveRecord::SubclassNotFound: The single-table inheritance mechanism failed to locate the subclass
- How to bypass SSL certificate verification in open-uri?
- “bin/rails: No such file or directory” w/ Ruby 2 & Rails 4 on Heroku
- How to handle Ruby on Rails error: “Please install the postgresql adapter: `gem install activerecord-postgresql-adapter'”
- What does #self.included(base) do in Ruby on Rails’ Restful Authentication?
- Rails4: How to permit a hash with dynamic keys in params?
- rails, simple_form, how to set selected index of a collection when page loaded?
- Hidden Features of Ruby on Rails [closed]
- How to run sidekiq in production server?
- Is the Lift framework as “easy” as Ruby on Rails or Django?
- An error occurred while installing mysql2 (0.4.8), and Bundler cannot continue
- Heroku Error R14 (Memory quota exceeded): How do I solve this?
- get validations from model
- How do I get an absolute URL for an asset in Rails 3.1?
- Do I have to manually uninstall all dependent gems?
- has_many :through with class_name and foreign_key
- Ruby on Rails i18n – Want To Translate Custom Messages in Models
- Naming Boolean columns in Rails
- How can I pass multiple attributes to find_or_create_by in Rails 3?
- Detect user agent in Rails 4 – read HTTP header