I am trying to manipulate the hash returned from Yahoo Finance for their Standard Quote using Ruby on Rails. I am new to Ruby and am getting a compile error in a view .erb file when I try to run the program. My objective is relatively straightforward - I want to display the Stock symbol, Bid and Ask prices and Corp name for each quote contained in the hash.
I stored the hash in an instance variable called @quote_info and pass this hash to the View.
The code in the view is as folows :
<h1>Stock Quote from Yahoo Finance</h1>
<p>Stock Symbol(s) Requested: <%= @quote_list %> </p>
<table>
<tr>
<th>Symbol</th>
<th>Bid Price</th>
<th>Ask Price</th>
</tr>
<% @quote_info.each |stock| do %>
<tr>
<td><%= stock.symbol %></td>
<td><%= stock.bid %></td>
<td><%= stock.ask %></td>
</tr>
<% end %>
</table>
I get a compile error on the each statement line , pointing to after the do term.
compile error
/home/lvl9/waf_projects/squotes_app/app/views/screenquotes/show.html.erb:18: syntax error, unexpected kDO
');@output_buffer.append_if_string= @quote_info.each |stock| do
^
Any thoughts would be much appreciated. I am tearing my hair out and cannot afford to lose any more.
Just a misplaced do
:
<% @quote_info.each do |stock| %>