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 8653079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:27:26+00:00 2026-06-12T14:27:26+00:00

I have two models – Client & Topic , with a HABTM relationship between

  • 0

I have two models – Client & Topic, with a HABTM relationship between them.

I am trying to generate a series of checkboxes of the topics, on the Client form partial.

This is what I am doing:

<% Topic.all.each do |topic| %>
  <% checked = @client.topics.include?(topic) %>
    <%= f.label(:name, topic.name) %> <%= f.check_box @topics, topic.id %>
<% end %>

This is the error I get:

undefined method `merge' for 1:Fixnum

I know one solution is to use check_box_tag, but that forces me to do the record updating of the associations manually.

So I would rather use the form_helper for the checkbox tag. The docs are a bit confusing to me.

How can I get this to work with f.check_box.

Thanks.

  • 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-12T14:27:27+00:00Added an answer on June 12, 2026 at 2:27 pm

    For whatever reason, the form helper doesn’t work with check_box.

    So, this is the code that works:

    <%= check_box_tag "client[topic_ids][]", topic.id, checked %>
    

    According to other answers for similar questions, the helper f.check_box is model bound and the value supplied to the checkbox is implicit from the model on the form. The issue is, I can’t figure out how to get the implicit value of the form_helper to produce the correct tag – i.e. client[topic_ids][], so I have had to resort to check_box_tag.

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

Sidebar

Related Questions

I have two models with a HABTM relationsip: users & interests... Basically the purpose
i have two models. Batch and Subject. The relation between them are Batch HAS_MANY
I have two models User and Category that have a HABTM association. I would
I have two models with the relationship Advisor belongsTo Room , Room hasMany Advisor
I have two models and i am trying to show the told credits of
I have two models generated with generate scaffolding, one is a LogBook the other
I have two models that has a manytomany relationship with a 'through' table in
I have two models, user & offline_user, and I want to use a dropdown
I have two models: Client and Invoice. Every client can have many invoices, every
I have two models indexed for searching (User and Item). I'm trying to do

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.