Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8990695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:33:23+00:00 2026-06-15T22:33:23+00:00

Event saves the section id’s in an array. But in the /events/1/edit view for

  • 0

Event saves the section id’s in an array. But in the /events/1/edit view for a newly created event, the expected checkboxes are not checked. I’m guessing because the default for checkbox values is booleans.

Event.last.newsletters #=> ["108", "115", "116", "117", "118", ""]

I have a CRUD for Event. Each Event can belong to multiple Sections. I have this displayed as a collection of checkboxes with the simpleform gem.

<%= simple_form_for @event do |f| %>
...
<%= f.collection_check_boxes :newsletters, Section.all, :id, :name, :input_html => { :class => 'checkbox' } %>

This results in the following html:

<span><input id="event_newsletters_1" name="event[newsletters][]" type="checkbox" value="1" /><label class="collection_check_boxes" for="event_newsletters_1">Newsletter 1</label></span>
<span><input id="event_newsletters_2" name="event[newsletters][]" type="checkbox" value="2" /><label class="collection_check_boxes" for="event_newsletters_2">Newsletter 2</label></span>
etc. etc.

When I create a new event or edit an event, the newsletter values are saved properly in the model.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:33:24+00:00Added an answer on June 15, 2026 at 10:33 pm

    Try specify the param :checked:

    <%= f.collection_check_boxes :newsletters,
                                 Section.all,
                                 :id,
                                 :name,
                                 :input_html => { :class => 'checkbox' },
                                 :checked => @event.newsletters %>
    

    Reference: how to preselect an association checkbox using simple_form

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using UpdatePanel to trigger a button click event, which saves some 100+
I am trying to add calendar events with my Android applicatiom. Event gets saved
What I have is 2 functions (edit and save), which are event handlers bound
We have repositories which have a Save method. They also throw a Created event
Event-delegation must be used to make events work after inserting DOM elements (i.e Ajax
i try to compile a java program but in the import section of the
I am a .NET Developer, but the question I am having is not related
I created the file: tinymce_compressor.sh $chmod +x tinymce_compressor.sh $ tinymce_compressor -bash: tinymce_compressor: command not
In Flash/ActionScript2, is it possible to capture the mousemove, buttonup and down event but
When code is placed onClick event it does not show open save dialog box

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.