```
class User < ActiveRecord::Base
  before_validation :ensure_login_has_a_value

  validates :login, :email, presence: true

  protected
    def ensure_login_has_a_value
      if login.nil?
        self.login = email unless email.blank?
      end
    end
end

```

Why it works but 

```
protected
  def ensure_login_has_a_value
    if login.nil?
      #self.login = email unless email.blank?
      # the change  
      login = email unless email.blank?
    end
  end

```

does not work??