Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8998577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:03:17+00:00 2026-06-16T00:03:17+00:00

I got my app working so that the user can only delete their own

  • 0

I got my app working so that the user can only delete their own comments but now im trying to add a link to the site but i only want the creator of the comment to be able to see the link.

I tried doing

<% if current_user %>

but when i do that it shows up on all comments and not just the user. I can do

<% if current_user.admin %> 

and that restricts only the admin to be able to see the delete links. I’ve also tried

 <% if @comment.user_id == current_user.id %>

that doesent work either. How can i do it so that the comment creator can only see the comments?

heres my view

_comments.html.erb

  <div class="container">
  <% @comments.each do |comment| %>
  <div class="comment">
<div class="gravatar_border">
  <%= gravatar_for comment.user, size: '49' %>
</div>

<div class="user_info_comments">
  <b><%= comment.user.name %></b>
  <%= comment.created_at.strftime("%b. %d  %Y") %>
</div>

<div class="user_comments">
  <%= simple_format comment.content %> 
  <%= pluralize comment.reputation_value_for(:votes).to_i, "vote" %>
  <%= link_to "", vote_comment_path(comment, type: 'up'), method: "post", class: ' icon-thumbs-up' %>
  <%= link_to "", vote_comment_path(comment, type: 'down'), method: "post", class: ' icon-thumbs-down' %>
  <% if @comment.user_id == current_user.id %>
  <%= link_to 'delete', comment, method: :delete, confirm: 'you sure?' %>
  <% end %>
   </div>
  </div>
 <% end %>
 <br />
</div>

heres my controller

comments_controller.rb

  def destroy
      @comment = Comment.find(params[:id])
      if @comment.user_id == current_user.id
        @comment.destroy
        flash[:notice] = "comment deleted!"
      else
        flash[:error] = "not allowed"
      end
   redirect_to :back
 end 

heres a link to the site http://www.batman-fansite.com

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:03:17+00:00Added an answer on June 16, 2026 at 12:03 am
    <% if comment.user_id == current_user.id %>
    

    and should work)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got style resources in WPF working so that in my App.xaml I can
I've got a working app that saves a document into a user-specified folder in
I've got a nice little web app working that brings down playlists and videos
I've got an app that's working pretty flawlessly in Chrome and FF, however, when
Bakground: I've got a legacy app I'm working on that uses DATE types for
I've got an app in Google App Engine that was working fine. I realized
I got an app I'm working on that uses static data from a sqlite
I've only been working on an iOS app now for a couple weeks so
I've got working spring MVC app and what I'm trying to do next is
In a simple app I'm working on, I've got three related assemblies: MyCompany.Geography.Windows.Forms which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.