Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs

Dashboard
Notifications
Mark all as read
Q&A

Why skipped_deleted variable is undefined for a new file? Question

+0
−0

I had created new HTML.erb file to separate following lines.

<% pingable = get_pingable(@comment_thread) %>

<% skipped_deleted = 0 %>
<% comments = @comment_thread.comments %>
<% if params[:inline] == 'true' %>
  <% comments = comments.where(deleted: false).take 5 %>
<% end %>
<% comments.each do |comment| %>
  <% if comment.deleted && !(current_user&.is_moderator && params[:show_deleted_comments] == "1") %>
  <% skipped_deleted += 1%>
  <% next %>
  <% elsif skipped_deleted > 0 %>
  <div class="widget--body">
      <div class="deleted-comments">
          <p>
              <% if skipped_deleted == 1 %>
              Skipping <%= skipped_deleted %> deleted comment.
              <% if current_user&.is_moderator %>
              <a href="?show_deleted_comments=1">Show it anyway.</a>
              <% end %>
              <% else %>
              Skipping <%= skipped_deleted %> deleted comments.
              <% if current_user&.is_moderator %>
              <a href="?show_deleted_comments=1">Show them anyway.</a>
              <% end %>
              <% end %>
          </p>
      </div>
  </div>
   <% skipped_deleted = 0 %>
  <% else %>
    <% skipped_deleted = 0 %>
  <% end %>
  <div class="widget--body">
      <%= render 'comments/comment', comment: comment, pingable: pingable %>
  </div>
<% end %>

This is how I was rendering

<%= render 'comments/fetch_comment' %>

I got following error in thread page.

ActionView::Template::Error: undefined local variable or method `skipped_deleted' for #<#<Class:0x000055945165c120>:0x00007f477151e608>

I was looking if some variable (called skipped_deleted) was declared in thread.html.erb. But, I couldn't find any. There's no variable which was used for indicating that skipped_deleted is integer. Although, why I am getting the above error in _fetch_comment.html.erb file? I don't have much more idea of ruby-on-rails.

Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

0 comment threads

0 answers

Sign up to answer this question »

This community is part of the Codidact network. We have other communities too — take a look!

You can also join us in chat!

Want to advertise this community? Use our templates!