<% = f.collection_select: address_id, @ customer.addresses,: id,: full_address,: include_blank =>" Please select "%>
I want to apply validation when I select "Please select" at the top without selecting in the form.
app/controllers/orders_controller.rb
params[:order][:address_id] == ""
flash[:notice] = "Please select"
redirect_to new_order_path
Looking at the value sent from the parameter, it was " "
, so change the equal statement to " "
.
When I wanted to implement this, I searched on Qiita and Google, but it did not come out at all. I posted. I keenly realized that I had to look closely at the terminal and check the value returned.