Answer the question
In order to leave comments, you need to log in
How to edit a boolean type field with checkboxes for several records of the same model in one form at once?
There is a table, one of the boolean type fields. You need to display a list of records from this table on the page and be able to edit this field by putting checkboxes and saving by clicking on one submit button. How to do this?
Answer the question
In order to leave comments, you need to log in
do it with ajax
class EatShitController < ApplicationController
# some code
def lets_eat
TriggerForYourPeaceOfShit.call(params[:ids]) # здесь передаешь массив
end
end
class TriggerForYourPeaceOfShit
def call(ids)
YourShittyModel.where(id: ids).each do |your_object|
your_object.toggle(:some_boolean_crap)
end
end
end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question