On Nov 30, 11:36 pm, John Victor <[EMAIL PROTECTED]>
wrote:
> I have a text file that has data in it which is perfectly formatted the
> way I want it.
> I have the following code in my controller to open the file and read
> each line into an array which I then call from my view. The problem is,
> I completely loose the formatting the way I'm doing it:

<%= ... %> basically just calls to_s on whatever the expression in
there evaluates to, and to_s on an Array is just the concatenation of
to_s called on everything in it. If you just want to display data from
the file, why not use @my_data = File.read(...) ?

Fred

>
> - from my controller:
> <code>
> def index
>         @ssh = Array.new
>         a = File.open("/usr/bin/my_data.dat")
>         a.each do |line|
>           [EMAIL PROTECTED](line)
>         end
> end
> </code>
>
> -from my view:
> <code>
> <%= @my_data %>
> </code>
>
> I'm thinking that maybe I shouldn't put the data in an array or maybe I
> should somehow loop through the array in my view in order to maintain
> the formatting of the text file?
>
> thanks
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to