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.
9acb6dd7bd59496bd005c4434a3dd475?d=identicon&s=25 Alex MacCaw (Guest)
on 2006-02-28 21:34
Is it possible to display the log files in the view?
Thanks in advance.
Bf66e10c8fc4abefebde0425e7f6f15a?d=identicon&s=25 Norman Timmler (Guest)
on 2006-03-01 10: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 Timmler

http://blog.inlet-media.de
9acb6dd7bd59496bd005c4434a3dd475?d=identicon&s=25 Alex MacCaw (Guest)
on 2006-03-01 17:40
Norman Timmler 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 Timmler
>
> http://blog.inlet-media.de

Thanks,
Also what would be the commands to clear the log file?
Bf66e10c8fc4abefebde0425e7f6f15a?d=identicon&s=25 Norman Timmler (Guest)
on 2006-03-01 18: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 Timmler

http://blog.inlet-media.de
C9806138c2b665621a723f0c88aff221?d=identicon&s=25 Lee O'Mara (Guest)
on 2006-03-01 18: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
9acb6dd7bd59496bd005c4434a3dd475?d=identicon&s=25 Alex MacCaw (Guest)
on 2006-03-01 18: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?
C9806138c2b665621a723f0c88aff221?d=identicon&s=25 Lee O'Mara (Guest)
on 2006-03-01 19: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.