Forum: Ruby on Rails Log Files in View

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Alex MacCaw (Guest)
on 2006-02-28 22:34
Is it possible to display the log files in the view?
Thanks in advance.
Norman T. (Guest)
on 2006-03-01 11:27
(Received via mailing list)
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
Alex MacCaw (Guest)
on 2006-03-01 18:40
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?
Norman T. (Guest)
on 2006-03-01 19:23
(Received via mailing list)
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 (Guest)
on 2006-03-01 19:25
(Received via mailing list)
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 (Guest)
on 2006-03-01 19:29
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?
Lee O'Mara (Guest)
on 2006-03-01 20:31
(Received via mailing list)
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-ra...
     rake, rake, rake your boat

--
  Lee
This topic is locked and can not be replied to.