The following error occurred, so I checked and passed the argument to path, but the error was not resolved.
Are there any other improvements?
ActionController::UrlGenerationError in Circles# show
No route matches {:action=>"destroy",:circle_id=>"5",:controller=>"circle_users",:id=>nil}, missing required keys: [:id]
<%=link_to 'Leave', circle_circle_user_path(@circle,@circle_user), method::delete,data:{confirm:"Circle #{@circle.name}"Would that be all right?" }, class: "btn btn-warning btn-lg" %>
・・・
route
circuit_circle_user DELETE/circles/:circle_id/circle_users/:id(.:format)circle_users #destroy
/app/views/circles/show.html.erb
<%[email protected] rcle_user?(current_user)%>
<%=link_to 'Leave', circle_circle_user_path(@circle,@circle_user), method::delete,data:{confirm:"Circle #{@circle.name}"Would that be all right?" }, class: "btn btn-warning btn-lg" %>
<!--- If you are not a member of the circle but are logged in -->
<%elsif current_user%>
<%if@apply%>
<%=link_to 'Cancel Application', circle_apply_path(@circle,@apply), method::delete, class:"btn btn-warning btn-lg"%>
<%else%>
<%=link_to 'Apply to join', circle_applies_path(@circle), method::post, class:"btn btn-warning btn-lg"%>
<%end%>
<%end%>
/app/controllers/circles_controller.rb
def show
@circle=Circle.find (params[:id])
@circleposts= @circle.circleposts.paginate (page:params[:page])
@circleposts=Circlepost.where(circle_id:@circle.id).all
end
By withdrawing, the user is logged in current_user fixed, isn't it?
resources:circles do
delete 'leave', on: —member
end
Or add an action with circle as the subject.
<%=link_to 'Leave', leave_circle_path(@circle), method::delete...
Isn't it okay to do that?
Then, when I clicked on it, it flew to Circles #leave
If you want to delete the user, you can retrieve it from the current_user and delete it.
I don't think users need to pass by parameters
© 2024 OneMinuteCode. All rights reserved.