我的观点:区块轨道3
<%= 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
块之后的所有内容都未呈现。我究竟做错了什么?在我看来,我如何在我的text_field_tag
中更新rating_phin.notes
而不是rec.notes
?
现在你应该换掉最后两行。要找到损坏的部件,尝试删除一些部件,直到它开始工作,然后逐个将它们移回去。 – ck3g 2013-02-20 04:37:42
这个例子通过创建一个辅助方法来管理很多这里正在进行的令人困惑的详细变量赋值,将大大有益于*。 – tadman 2013-02-20 04:38:47