Log Files in View

Is it possible to display the log files in the view?
Thanks in advance.

Am Dienstag, den 28.02.2006, 21:34 +0100 schrieb Alex MacCaw:

Is it possible to display the log files in the view?
Thanks in advance.

Rails views are ERB files and inside you can do anything what is doable
with ruby.

If you want to display the current log file for example:

<%= File.open(“#{RAILS_ROOT}/log/#{RAILS_ENV}.log”) { |f| f.read } %>


Norman T.

http://blog.inlet-media.de

Norman T. wrote:

Am Dienstag, den 28.02.2006, 21:34 +0100 schrieb Alex MacCaw:

Is it possible to display the log files in the view?
Thanks in advance.

Rails views are ERB files and inside you can do anything what is doable
with ruby.

If you want to display the current log file for example:

<%= File.open(“#{RAILS_ROOT}/log/#{RAILS_ENV}.log”) { |f| f.read } %>


Norman T.

http://blog.inlet-media.de

Thanks,
Also what would be the commands to clear the log file?

Am Mittwoch, den 01.03.2006, 17:40 +0100 schrieb Alex MacCaw:

Also what would be the commands to clear the log file?

File::truncate(“#{RAILS_ROOT}/log/#{RAILS_ENV}.log”, 0)

Norman T.

http://blog.inlet-media.de

Lee O’Mara wrote:

Alex MacCaw wrote:

Thanks,
Also what would be the commands to clear the log file?

Now:

rake clear_logs

Rails 1.1

rake logs:clear


Lee

Can you run this command inside a controller?

Alex MacCaw wrote:

Thanks,
Also what would be the commands to clear the log file?

Now:

rake clear_logs

Rails 1.1

rake logs:clear


Lee

Alex MacCaw wrote:

rake logs:clear

Can you run this command inside a controller?

No, those are Rake[1]tasks. They are run from the command line.

You can list all the available rake tasks for your app with: rake -T.

Geoffrey Grosenbach recently wrote up a nice piece about Rake and Rails
[2]

  1. http://rake.rubyforge.org/
    RAKE â?? Ruby Make

  2. http://nubyonrails.com/articles/2006/02/25/rake-rake-rake-your-boat
    rake, rake, rake your boat


Lee