我的观点:
<%= form_tag(rate_url) do %>
<%= hidden_field_tag :prod_id, params[:product_id] %>
<%= hidden_field_tag :rating_set_id, params[:rating_set_id] %>
<span class = "heading"> Recommendations </span>
<div><%= submit_tag 'Submit Ratings', :class => " btn right" %></div>
<span id = "rate_more_link">
<%= link_to "Rate More Products", products_path(:rating_set_id => params[:rating_set_id])%>
</span>
<br/>
<div id ="prods_container">
<% @recommendations.each do |rec| %>
<% url_raw = URI.parse("url_to_parse") %>
<% url = Net::HTTP.get_response(url_raw).body %>
<% if url.empty? %>
<% @title = "Product Unavailable via API" %>
<% @url = "#{rec.wmt_id}" %>
<% @cover_img = "_180X180.jpg" %>
<% @price = "Product Unavailable via API" %>
<% else %>
<% begin %>
<% @response1 = JSON.parse(url) %>
<% @title = @response1["ProductName"]%>
<% @url = "{@response1["ProductUrl"]}"%>
<% @cover_img = @response1["ImagePath"]%>
<% @price = @response1["currentItemPrice"]%>
<% rescue %>
<% end %>
<% end %>
<div id ="prod">
<span class = "radio_button">
<%= hidden_field_tag "recommendation_ratings[#{rec.id}][recommendation_id]", rec.id %>
<%= radio_button_tag "recommendation_ratings[#{rec.id}][rating]", '3'%> Good
<%= radio_button_tag "recommendation_ratings[#{rec.id}][rating]", '2'%> Fair
<%= radio_button_tag "recommendation_ratings[#{rec.id}][rating]", '1'%> Bad
<%= radio_button_tag "recommendation_ratings[#{rec.id}][rating]", '0'%> N/A
</span>
<div>
<a href='<%= @url %>' target="_blank">
<img src='<%= @cover_img %>' class='product_image_rec_table'></img>
</a>
</div>
<div class = "rec-desc">
<div class = "small"><b>Wmt ID: </b><%= rec.wmt_id %></div>
<div class = "small"><b>Title: </b><%= @title %></div>
<div class = "small"><b>Price: </b>$<%= @price %></div>
<div class = "em">
<b>Current Rating: </b>
<% rec.ratings.each do |rating_phin| %>
<%= rating_phin.label %>
<% end %></div>
<br/>
</div>
<div id="rec_note_text">
<%= text_field_tag "recommendation_ratings[#{rec.id}][notes]", "#{rec.notes}" ,:id => "rec_note_text", :placeholder => 'Enter Notes..'%>
</div>
</div>
<% end %>
<% end %>
</div>
我试图将块<% end %>
从Current Rating
块移动到末尾,以便我可以rating_phin
在我的变量中调用变量text_field_tag
,但是当我将块移动<% end %>
到视图的末尾时,Current Rating
块之后的所有内容都不会被渲染。我究竟做错了什么?如何在视图结束时更新rating_phin.notes
而不是rec.notes
在我的视图中?text_field_tag