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 H.”.

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:

  • <%= 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 %>
  • I attache user_pages_spec.rb file. Please find it.

    How to fix this error?

    Kind regards

    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.

    On Wednesday, July 9, 2014 7:02:09 AM UTC+2, Ruby-Forum.com User wrote:

    When i sign in, delete link is not appear. I can’t able to solve this
    //= require_tree .


    Posted via http://www.ruby-forum.com/.

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

    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

    .
    .
    .
    .
    .

    Serguei C. wrote in post #1152018:

    On Wednesday, July 9, 2014 7:02:09 AM UTC+2, Ruby-Forum.com User wrote:

    When i sign in, delete link is not appear. I can’t able to solve this
    //= require_tree .


    Posted via http://www.ruby-forum.com/.

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

    No, First I will sign in. Then after sign in when i click on “Users”.
    After then Page generate of “All users”. In that page “Delete” link
    should appear

    BUT

    Delete link does not appear. How can I fix this problem?

    Kind regards.

    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.

    On Wednesday, July 9, 2014 7:02:09 AM UTC+2, Ruby-Forum.com User wrote:

    When i sign in, delete link is not appear. I can’t able to solve this
    //= require_tree .


    Posted via http://www.ruby-forum.com/.

    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.

    This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

    | Privacy Policy | Terms of Service | Remote Ruby Jobs