i have argument error when i use devise helper current_user

I add before_action :authenticate_user! but it isn`t work

repo: https://github.com/d1mentor/robostep

error screenshot: error

my controller:

class UsersController < ApplicationController
  # Встроенный в девайз фильтр — посылает незалогиненного пользователя
  before_action :authenticate_user!

  # Задаем объект @user для шаблонов и экшенов
  before_action :set_current_user

  helper_method :user_avatar

  def user_avatar(user)
    if user.avatar_url.empty? then
      avatar_url = "https://i.guim.co.uk/img/media/26392d05302e02f7bf4eb143bb84c8097d09144b/446_167_3683_2210/master/3683.jpg?width=1200&height=1200&quality=85&auto=format&fit=crop&s=49ed3252c0b2ffb49cf8b508892e452d"
    else
      avatar_url = user.avatar_url
    end
  end

  def index

  end

  def set_current_user
    @user = current_user
  end
end

My view:

<div class="container text-center">
 <div class="row">

    <h2>Моя страница</h2>

    <%= image_tag(user_avatar) %>

</div>
</div>

Upvotes: 0

Views: 25

Answers (1)

veritas1
veritas1

Reputation: 9180

The error in the screenshot is not to do with the devise helper current_user. It is in regard to the user_avatar helper.

In your view, you are calling the method with 0 arguments:

<%= image_tag(user_avatar) %>

But the method is defined with 1 parameter:

  def user_avatar(user)

Hence the wrong number of arguments error in the screenshot.

Upvotes: 1

Related Questions