I am making a clone app for flea market apps.
On the product detail page, I want to change the display under the following conditions, but it does not work.
・ Only the seller who is logged in will see the "Edit/Delete Product Button".
・ Only users other than the logged-in seller will see the "Go to purchase screen button".

① Whether the user is logged in
② Whether the user who accessed the product details screen is the seller
I'm trying to make a conditional branch.

Corresponding source code


<% if user_signed_in?%>
    <% if current_user.id == @ item.user_id%>
    <% = link_to'Edit product', item_path (@item) method:: get, class: "item-red-btn"%>
      <p class ='or-text'>or</p>
    <% = link_to'Delete', "#", method:: delete, class:'item-destroy'%>
  <% elsif? ?? ?? = Current_user.id? ?? ?? %>
    <% = link_to'Proceed to purchase screen', "#", class: "item-red-btn"%>
<% end%>


class ItemsController
What I tried

Regarding (1), we are trying to describe that the currently logged-in user is the user associated with the product.
Regarding (2), I searched various descriptions of elsif conditions that apply to the conditions, but I could not solve it at all.
Could anyone please teach me?
This is my first question, and I may be missing the necessary information and code.
We will present it as soon as you teach us.

Supplementary information (FW/tool version, etc.)

Please provide more detailed information here.

  • Answer # 1

    It's okay to use else instead of elsif

Related articles