mardi 23 avril 2019

Do partial variables override helper methods?

I have some helper method that called current_language and sometimes I send current_language in the local_assigns.

So I want to assign my partial variable by the local_assigns's current_language in case if it's sent.

But I found something weird, in the following code:

<%
  binding.pry
  x = 4

  current_language = local_assigns[:current_language] || current_language
%>

In line 3 when debugging current_language equals nil even before overriding.

I expect it shall still equal the helper method until it's overrided.

So what is going on?

Aucun commentaire:

Enregistrer un commentaire