Home>

Currently, we are making different update processes depending on the selection of the select box.
It is a select box like the one below,
The choices are "None", "Approve", "Reject", "Applying" and the column name is identifyr_reply.
The column name of the check box on the right is change, and the check box is checked, and the select option is selected to update.

In the case of "None", "Approve" and "Reject", the column is updated without any problem and flash appears.
If i do not check or if the select is "Applying", the same flash as "None", "Approve", and "Reject" will appear.
In the 8th line of the controller, the check box is checked, and the content progresses only when "None", "Approve", and "Reject".
I don't understand why I don't get an exception error.

Excuse me, can you tell me how?

def update_overtime_notice
    ActiveRecord :: Base.transaction do
      o1 = 0
      o2 = 0
      o3 = 0
      overtime_notice_params.each do | id, item |
        if item [: invoker_reply] .present?
          if (item [: change] == "1")&&(item [: identifyr_reply] == "None" || item [: identifyr_reply] == "Approve" || item [: identifyr_reply] == "Negative")
          attendance = Attendance.find (id)
          user = User.find (attendance.user_id)
            if item [: invoker_reply] == "None"
              o1 + = 1
              item [: overtime_finished_at] = nil
              item [: tomorrow] = nil
              item [: overtime_work] = nil
              item [: invoker_check] = nil
            elsif item [: invoker_reply] == "Approval"
                  item [: invoker_check] = nil
              o2 + = 1
          attendance.indicater_check_anser = "Approved"
            elsif item [: invoker_reply] == "denial"
                  item [: invoker_check] = nil
              o3 + = 1
          attendance.indicater_check_anser = "denied"
            end
            attendance.update_attributes! (item)
          end
        end
      end
      flash [: success] = "[Overtime application] # {o1} none, # {o2} approved, # {o3} denied"
        redirect_to user_url (params [: user_id])
    end
  rescue ActiveRecord :: RecordInvalid
      flash [: danger] = "The update was canceled because there was invalid input data."
      redirect_to edit_overtime_notice_user_attendance_url (@ user, item)
  end
  • Answer # 1

    I don't understand why I don't get an exception error.

    On the contrary, did you think "Why fly to the exception"? If the condition is not met, I think there is an element that raises an exception simply by not processing.

  • Answer # 2

    I have another problem
    if (item [: change] == "1")&&a || b || c
    Part of.

    if (item [: change] == "1")&&(a || b || c)

    I have to do it.