Rails 3.0.7, Windows 7, NetBeans 6.9.1, JRuby 1.5.1, Ruby 1.8.7vẽ một phần không được hiển thị
Tôi có app/views/browsing/index.rhtml
với phần có liên quan này, tập trung vào các render
gọi:
<table>
<tr>
<th><em><%=I18n.t('browsing.actions')%></em></th>
<% colnames = @_controller.model_class.column_names %>
<% colnames.each do |name| %>
<% render :partial => 'browsing/header_field', :locals => {:name => name} %>
<% end %>
</tr>
Và tôi có app/views/browsing/_header_field.rhtml
với nội dung sau:
<% puts "DEBUG: rendering " + name + " field." %>
<% if @_controller.orderables.include?(name.to_sym) %>
<%
otext = ''
oopts = @_controller.orderings[name];
if !oopts.nil?
otext += ' ' + (oopts[:is_asc] ? '↓' : '↑')
otext += '<span class="small">'+oopts[:prio].to_s+'</span>'
end
%>
<th><%=link_to(name.tr('_',' '), { :controller => controller_path, :action => 'index', :o => name }, {:class => 'sort'})%>
<%=((otext=='' || @_controller.orderings.size<=1) ? raw(otext) : link_to(raw(otext), { :controller => controller_path, :action => 'index', :o => name, :x => true }, {:class => 'delete_sort', :title => I18n.t('browsing.delete_sort')}))%></th>
<% else %>
<th><%=name.tr('_',' ')%></th>
<% end %>
các debug-in (dòng đầu tiên) được thực hiện đúng cách, tôi có thể nhìn thấy nó trong cửa sổ đầu ra. Tôi có thể sử dụng IDE NetBeans để xem việc thực thi dòng tệp này theo dòng, nó xảy ra như được mong đợi
Vấn đề là kết quả của việc hiển thị này bằng cách nào đó bị loại bỏ trên cửa sổ, không có gì (không có bảng ô tiêu đề) trong HTML được hiển thị cuối cùng. Đó là trả lại (chỉ là một phần có liên quan):
<table>
<tr>
<th><em>Actions</em></th>
</tr>
Cửa sổ đầu ra sản xuất này:
DEBUG: rendering id field.
DEBUG: rendering inm_device_id field.
DEBUG: rendering changes_id field.
Started GET "/changes_and_devices" for 127.0.0.1 at Wed Jun 08 11:50:01 +0200 2011
Processing by ChangesAndDevicesController#index as HTML
ChangeAndDevice Load (2.0ms) SELECT `changes_and_devices`.* FROM `changes_and_devices` ORDER BY id desc LIMIT 20 OFFSET 0
SQL (18.0ms) SELECT COUNT(*) FROM `changes_and_devices`
Rendered browsing/_header_field.rhtml (6.0ms)
Rendered browsing/_header_field.rhtml (6.0ms)
Rendered browsing/_header_field.rhtml (5.0ms)
Rendered browsing/index.rhtml within layouts/application (189.0ms)
Completed 200 OK in 245ms (Views: 207.0ms | ActiveRecord: 20.0ms)
Tất cả các gợi ý được hoan nghênh! Cảm ơn trước!
Ôi Chúa ơi ... Đó đau. Cảm ơn bạn! – Notinlist
không bao giờ nhớ ;-) bạn được chào đón. – pduersteler