The user index does not display delete links

I am using Ruby 2.0.0 and Rails 4.0.5. I follow "Ruby on Rails tutorial
by Michael Hartl".

I am trying to implement **"The destroy action"** (section 9.4.2).

Administrative users should see delete link

BUT

When i sign in, delete link is not appear. I can't able to solve this
issue.

Test suite run successfully.

My application.js file contain:

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap
//= require_tree .

_user.html.erb:

<li>
  <%= gravatar_for user, size: 52 %>
  <%= link_to user.name, user %>
  <% if current_user.admin? && !current_user?(user) %>
    > <%= link_to 'delete', user, method: :delete,
                                  data: { confirm: "You sure?" } %>
  <% end %>
</li>

I attache user_pages_spec.rb file. Please find it.

How to fix this error?

Kind regards

Attachments:
http://www.ruby-forum.com/attachment/9872/user_pages_spec.rb

If your tests are passing, try some debugging.
Check your current_user helper method make sure its working the way its supposed to work.

I would also check sessions to make sure the current user is available.

How do you sign in , - as admin or not ? That’s the question :slight_smile:

Serguei Cambour wrote in post #1152018:

dasibre wrote in post #1151967:

If your tests are passing, try some debugging.
Check your current_user helper method make sure its working the way its
supposed to work.

I would also check sessions to make sure the current user is available.

I am providing sessions_helper:

module SessionsHelper

.
.
.
.
.

  def current_user=(user)
    @current_user = user
  end

  def current_user
    remember_token = User.digest(cookies[:remember_token])
    @current_user ||= User.find_by(remember_token: remember_token)
  end

   def current_user?(user)
    user == current_user
  end

.
.
.
.
.

The ‘delete’ link will be displayed ONLY if the current user (i.e. the user which is actually signe in) is ADMIN:

if current_user.admin?

So check the user credentials you use to sign in, - it is as easy as it is.

The 'delete' link will be displayed ONLY if the current user (i.e. the
user
which is actually signe in) is ADMIN:

if current_user.admin?

So check the user credentials you use to sign in, - it is as easy as it
is.

Yes, It's as easy as it is after you giving me direction. I solved this
problem

Thank you.