On Tue, Jul 29, 2008 at 9:56 AM, Michael Zellmann
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
> I have an rails application that needs to read a file from its own
> directories. Say I put in in the config folder, and call it
> sometext.txt. In a controller I have
>
> f = File.new(File.join(RAILS_ROOT, ''config'',
''sometext.txt''))
>
> then text = f.read gets me the information.
>
> This works fine in my development environment, with the side effect that
> the file contents also get printed to my console. However, this seems to
> cause a big problem when I deploy the application. The production server
> does not want to have any print activity, so, I get an error statemtn
> that Rails application did not start successfully - same as if I had
> left a puts statement somewhere in the code.
>
> There must be a straight-forward way to read the file without any output
> ?
What are your goals with this approach? Is this a configuration thing?
If so, you might look into using YAML for config files and then you
can load up your yml file and define variables to access in your
application.
Robby
--
Robby Russell
Chief Evangelist, Partner
PLANET ARGON, LLC
design // development // hosting
http://www.planetargon.com/
http://www.robbyonrails.com/
aim: planetargon
+1 503 445 2457
+1 877 55 ARGON [toll free]
+1 815 642 4068 [fax]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---