我试图根据一些条件更新一小组记录。我已将该组存储在名为@group_to_randomize的变量中。它实际上并没有保存,所以也许我使用update_all错了?或者与@group_to_randomize的分配有关?值得注意的是,@ treatment是一个局部变量,在上面定义和分配。
if (@group_size_input >= 6 ) and (@group_size_input <= 10 )
@group_to_randomize = Subject.where("study_site = ? AND treatment_group is null", params[:site_input].to_i).order("created_at ASC").limit(@group_size_input)
if params[:site_input] != '' and params[:test_rand_variable] != nil
if @group_to_randomize.update_all(treatment_group: @treatment)
#I get to here, but nothing appears to be saving to the database.
flash[:success] = "Subjects randomized, and assigned the #{@treatment_name}"
else
flash[:failure] = "Subjects failed to save."
end
...
非常感谢任何帮助。