I would like to point to a message when validation fails, but the edit action gives an error message without any problems, but only during the crate action.Please let me know if you know anything.
I checked and found that many people had problems with local:true, but it seemed that there was no problem.
<%=form_with(model:@circle,local:true)do|f|%>
<%=render'shared/circle_error'%>
<%=f.label: name %>
<%=f.text_field:name,class:'form-control'%>
<%=f.label: Qualifications %>
<%=f.text_field:qualification, class:'form-
<%=f.submit "create", class: "btn btn-warning" %>
<%end%>
def new
@circle=Circle.new
end
def create
@circle=Circle.new(circle_params)
@circle.owner=current_user
If @circle.save!
@circle_user=CircleUser.new(circle_id:@circle.id, user_id:current_user.id)
@circle_user.save!
flash[:success] = "Created"
redirect_to root_url
else
render 'new'
end
end
def show
@circle=Circle.find (params[:id])
@apply=Apply.find_by(@apply)
@circle_user=CircleUser.find_by (circle:@circle, user:current_user)
end
default
@circle=Circle.find (params[:id])
end
default update
@circle=Circle.find (params[:id])
[email protected](circle_params)
flash[:success] = "Circle information updated"
redirect_to@circle
else
render 'edit'
end
end
<%[email protected] y?%>
<divid="error_explanation">
<div class="alert alert-danger">
The input error is <%=pluralize(@circle.errors.count, "There were cases")%>.
</div>
<ul>
<%@circle.errors.full_messages.each do|msg|%>
<li><%=msg%></li>
<%end%>
</ul>
</div>
<%end%>
I understand how to solve it.The reason was that the ! of save! was attached.
© 2024 OneMinuteCode. All rights reserved.