Home>
<% = form_with (model: @user, url: attendances_update_month_approval_user_path (@user), method :: patch, local: true) do | f |%>
<% = f.hidden_field: individual_reply_month,: value =>"Applying"%>

As above, send value =>"pending" in hidden_field

<% @ attendances.each do | attendance |%>
<% if attendance.user_id == user.id&&attendance.indicater_reply_month == "Applying"&&current_user.name == attendance.indicater_check_month%>
<Tbody>
  <td><% = l (attendance.month_approval, format:: short2)%>month</td>
  <td><% = f.select: invoker_reply_month, Attendance.indicater_reply_months.keys, {prompt: false}, {class: "form-control input-sm", required: true}%></td>
↑ Here
  <td><% = f.check_box: change_month%></td>
  <td><% = link_to "confirm", verifacation_user_path (user.id, worked_on: attendance.worked_on), class: "btn btn-primary", target:: _blank%></td>
</Tbody>
<% end%>
<% end%>

I want to initially display "Applying" in f.select on the 5th line from the top, but it is blank.
Could you please tell me the solution?

By the way, the f.select choice uses enum

enum indicater_reply_month: {"None" =>0, "Approve" =>1, "Denial" =>2, "Applying" =>4}, _prefix: true
def edit_month_approval_notice
@user = User.find (params [: id])
@users = User.joins (: attendances) .group ("users.id"). where (attendances: {indicater_reply_month: "pending"})
@attendances = Attendance.where.not (month_approval: nil) .order ("worked_on ASC")
@first_day = params [: date] .nil ??
 Date.current.beginning_of_month: params [: date] .to_date
@last_day = @ first_day.end_of_month
one_month = [* @ first_day .. @ last_day]
@attendances = @ user.attendances.where (worked_on: @ first_day .. @ last_day) .order (: worked_on)
    unless one_month.count == @ attendances.count
      ActiveRecord :: Base.transaction do
        one_month.each {| day | @ user.attendances.create! (Worked_on: day)}
      end
      @attendances = @ user.attendances.where (worked_on: @ first_day .. @ last_day) .order (: worked_on)
    end
  rescue ActiveRecord :: RecordInvalid
    flash [: danger] = "Failed to get page information, please re-access."
    redirect_to root_url
  end

private
 def month_approval_params
  params.require (: user) .permit (attendances: [: month_approval,: invoker_reply_month,: invoker_check_month]) [: attendances]
 end
end
  • Answer # 1

    I don't think there was a value option in f.hidden_field.
    Please check the parameters sent by log.
    Since it is indicater_reply_month, isn't the value a number rather than the character string'pending'?
    What value is in this select?
    Maybe prompt: I wonder

Related articles