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?
To make things more specific, here is my code:
file: app/controllers/application.rb
def write_to_log(msg)
File.open(“logfile.txt”, “a”) do |file|
now = DateTime.now
file.puts("#{now}\t#{msg}")
end
end
def set_lang
code = params[:id]
if code != “el” && code != “en” && code != “de”
code = “el”
end
@lang = code
write_to_log("set_lang\t" + code)
cookies[:lang] =
{
:value => code,
:expires => Time.now + 1.year,
:path => '/'
}
# redisplay the page in the new language
redirect_to request.env["HTTP_REFERER"]
end