Reputation: 41
I have a variable 'messages' of type array and whenever I put it into the terminal it has tabs and new lines but whenever I save messages to a variable and display it on my rails application, it no longer has these. How do I fix this so it shows the new lines and tabs on the rails app.
Code for outputting to the terminal in model (User):
def runMessages
messages << stdout.read
messages << stderr.read
puts "OUTPUT IS:" + messages[0]
messages
end
Code in controller for saving to variable:
messages = @user.runMessages
@user.output = messages[0]
Code in views:
<p> <%= @user.output %> </p>
In the terminal it looks something like this:
Beginning run ...
Done.
While on the application it looks like this:
Beginning run...Done.
Upvotes: 1
Views: 154
Reputation: 9523
Use the HTML <pre>
tag.
<pre> <%= @user.output %> </pre>
You could also use it in combination with the <code>
tag, see this question for the difference.
Upvotes: 2