I have just started learning Rails and Ruby. I have succeeded in
building an application so far. However, recently I tried embedding
some ruby code in one of my html.erb files with the intention of
further formatting the string that was being output. The original
string was a set of lines with tab-delimited fields. So, I wanted to
put it in pretty print HTML. For this, i used some string functions
such as String.lines. When I try to view the said page, I get the
following error:
What is @longshortgene.parsed_blast_report ? Did you mean each_line ?
Also the variable you're using inside the block should be line, not
@line (it's got to match what is in between the | |)
You should also parse the result through h or you may output invalid
html
Thanks, Fred. @longshortgene.parsed_blast_report is a string, which is
a set of lines, each line consisting of tab-delimited fields. When I
print @longshortgene.parsed_blast_report, it prints correctly. It is
only when I try to parse it that I get the "undefined method" error
for the method "lines". Do I need to create a new String object first
using @longshortgene.parsed_blast_report and then use the method lines
on it? I am going to try that next.
I corrected '@line' to 'line' and the error still persists.
Thanks, Fred. @longshortgene.parsed_blast_report is a string, which is
a set of lines, each line consisting of tab-delimited fields. When I
print @longshortgene.parsed_blast_report, it prints correctly. It is
only when I try to parse it that I get the "undefined method" error
for the method "lines". Do I need to create a new String object first
using @longshortgene.parsed_blast_report and then use the method lines
on it? I am going to try that next.
String doesn't have a lines method before ruby 1.8.7.