Home Best way to use collection_checkboxes in rails view with extra attributes in intermediate model
Reply: 0

Best way to use collection_checkboxes in rails view with extra attributes in intermediate model

user828
1#
user828 Published in May 27, 2018, 3:36 am

Any example of how to use rails collection_check_boxes in a rails view with a has_many through model with extra attribute?

I need to associate Post with Categories, and I'm using has many through post_categories. I want to add comments the relationship, so I added an extra attribute to the intermediate table, comment, which is a string.

I want to render a form in an admin panel where I am creating a new category and I want to associate it with any existing post, so I use f.collection_check_boxes, but in the same form I also want to add a text box where the user can add any comment when adding the relationship.

How can I do this with rails collection_check_boxes, so that when I submit my associated posts to my new category also I include comments in the same form?

Best

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.302423 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO