Calls between methods of application.rb

In a rails application,
I have a set_lang() and a write_to_log() method in
app/controllers/application.rb

set_lang() calls write_to_log().
Nothing happens. I should expect that write_to_log is either called or
an exception is thrown. However, it seems that it is silently ignored.
To prove this I called write_to_log00(), which does not exist. Still
the same behavior.

Is this normal?
Is there a workaround?

Nikos Kanellopoulos wrote:

In a rails application,
I have a set_lang() and a write_to_log() method in
app/controllers/application.rb

set_lang() calls write_to_log().
Nothing happens. I should expect that write_to_log is either called or
an exception is thrown. However, it seems that it is silently ignored.
To prove this I called write_to_log00(), which does not exist. Still
the same behavior.

Is this normal?
Is there a workaround?

You should :

  • post your code
  • post it to the Ruby On rails forum instead of the Ruby (maybe you’ll
    get more help)

If your code looks like

def write_to_log
#blablabla
set_lang = something
#blablabla
end

Then it won’t work, because Ruby assumes that set_lang is a local
variable.
Do this instead (add “self.”) :

def write_to_log
#blablabla
self.set_lang = something
#blablabla
end

Hope this helps. If it doesn’t, I’m sure you’ll get more responses if
you post your piece of code :slight_smile: