I'm using ruby 2.6.5 on my local machine. I also use the same ruby version on heroku machine.
However i got weird error on using heroku.
if i defined a method like:
def current_admin
@current_admin ||= 'yana'
end
It works perfectly on my machine, on heroku it will raise a NameError:
NameError (`@` is not allowed as an instance variable name)
however when i do:
def current_admin
return @current_admin if defined?(@current_admin)
@current_admin = 'yana'
end
It works on both machine.
What exactly is the difference that cause first syntax fails on heroku?
* Update *
The diff i made to make it work on heroku.
def current_account
- @current_account ||= AccountSession.find
+ return @current_account if defined? @current_account
+
+ @current_account = AccountSession.find
end