Friday, March 07, 2008

In which I demonstrate that I think better in the morning

Well snot that was easy.

I want to read data from a file and push it to the screen. How to do this was not obvious in Ruby/Rails, or at least it was not at midnight last night.

Read the book this a.m. and LO it's so obvious in retrospect and LO five minutes later it's working on my test server.

Controller

(snip)
def contact
arr = IO.readlines("foo.txt")
@name = arr[0]
@email = arr[1]
@phone = arr[2]
@street = arr[3]
@geo = arr[4]
end
(snip)


View

<%= @name %>
<%= @email %>
(and so on)


Duh. I share this not to show how cleaver I am but because I cannot believe how obvious it all is. Duh.
blog comments powered by Disqus