dimanche 12 janvier 2020

How works these methods in controllers, assets in js?

I have this example
And i wanna understand what it is " ||= " in this method? How it works?

First segment

 def current_user
            @current_user ||= User.find(session[:user_id]) if session[:user_id]
          end

also, i dont know what does (function()) mean in Ruby on rails. Its not simple function(), why is it inside brackets?

Second example

(function() {
  this.App || (this.App = {});

  App.cable = ActionCable.createConsumer();

}).call(this);

Aucun commentaire:

Enregistrer un commentaire