Ruby on rails 为什么要将此字符串转换为BigDecimal?
我正在为我老板度假期间调试rails应用程序。我们公司有一个应用程序,可以用来填写时间表和查看客户机票。在“打开票证”页面上,有一个列,其中包含票证的简要说明。我们在Ubuntu上有一个用于生产的环境,一个用于开发的XP环境,这两个环境都没有遇到bug。但是如果我在Windows7或更高版本上运行环境,则描述不会显示为字符串,而是显示为BigDecimal,通常为“0.0”。一些票据显示其他数字。我会发布截图,但为了公司的隐私,我不会发布 到目前为止,我知道的是:我们使用的数据库在表中显示了实际的描述。视图和控制器都显式地转换为字符串,当我去掉代码中的Ruby on rails 为什么要将此字符串转换为BigDecimal?,ruby-on-rails,ruby-on-rails-3,Ruby On Rails,Ruby On Rails 3,我正在为我老板度假期间调试rails应用程序。我们公司有一个应用程序,可以用来填写时间表和查看客户机票。在“打开票证”页面上,有一个列,其中包含票证的简要说明。我们在Ubuntu上有一个用于生产的环境,一个用于开发的XP环境,这两个环境都没有遇到bug。但是如果我在Windows7或更高版本上运行环境,则描述不会显示为字符串,而是显示为BigDecimal,通常为“0.0”。一些票据显示其他数字。我会发布截图,但为了公司的隐私,我不会发布 到目前为止,我知道的是:我们使用的数据库在表中显示了实际
时,错误仍然存在。我将类类型发送到一个日志文件,确认它是一个BigDecimal。从我的机器上运行生产代码时,错误仍然存在。我认为这可能是一个操作系统兼容性问题。或者在数据库和应用程序本身之间的某个地方,数据正在转换为一个我还不知道的文件中的bigdecim。我运行的是rails 3.0.7和ruby 1.9.2p290
以下是我认为可疑的代码:
<div id="page_center">
<div id="branding_row">
<%= label_tag("Show_Open", "Show Open Tickets",{:class => 'page_label'}) -%>
</div>
<div id="tabs">
<ul>
<% @locationHash.keys.each do |keyItem| %>
<li><a href="#tabs-<%= keyItem %>"><%= keyItem %></a></li>
<% end %>
</ul>
<% @locationHash.keys.each do |keyItem| %>
<div id="tabs-<%= keyItem %>">
<table >
<tr >
<th style="width:50px; empty-cells:hide;">WO#</th>
<th style="width:125px; empty-cells:hide;">Customer Name</th>
<th style="width:125px; empty-cells:hide;">Description</th>
<th style="width:65px; empty-cells:hide;">Tech</th>
<th style="width:125px; empty-cells:hide;">Date/Time</th>
</tr>
<% @locationHash[keyItem].each do |ticketItem| %>
<tr>
<td><%= ticketItem.work_order.to_s %></td>
<td><%= ticketItem.customer_name.to_s %></td>
<td><%= ticketItem.woDesc.to_s %></td>
<td><%= ticketItem.tech.to_s %></td>
<td><%= ticketItem.created_at.to_s %></td>
</tr>
<% end %>
</table>
</div>
<% end %>
</div>
</div>
<div id="right_column">
</div>
不可能有一个。to\f
在任何地方浮动,是吗?@ChaseGilliam我一直在视图和控制器中搜索。to\f
和。to\d
,但没有找到。你能发布ticketem的模式部分吗?也许是加载此视图的控制器操作?@ChaseGilliam您能澄清TicketItem的schema部分是什么意思吗?我发布了tickets controller.Schema.rb中定义tickets属性的部分。
class TicketsController < ApplicationController
def populate_workOrders
@customerId = params[:customerID]
logger.debug "@customerId = #{@customerId.to_s}"
@tickets = Ticket.where(:customer_id => @customerId)
logger.debug "@tickets size = #{@tickets.size.to_s}"
@outputTickets = Array.new
@tickets.each {|ticketItem|
#select only tickets with specific open/usable codes
if ['ARV','CAN','COM','D','H','O','S','PERM','CB','CN'].include?( ticketItem.woStatus )
logger.debug "workorder - #{ticketItem.work_order} status - #{ticketItem.woStatus}"
@outputTickets << ticketItem
end
}
respond_to do |format|
format.json { render :json => @outputTickets.to_json }
end
end
def show_open
logger.debug "****** inside Tickets - show_open ******"
@customersHash = Hash.new
@locationHash = Hash.new
@tempTicketArray = Array.new
# @customers = Customer.all
# logger.debug "@customers size = #{@customers.size.to_s}"
# @customers.each {|customerItem|
# @customersHash[customerItem.id] = customerItem
# }
## updates names
# @allTickets = Ticket.all
# @allTickets.each{|ticketItem|
# ticketItem.customer_name = @customersHash[ticketItem.customer_id].name
# ticketItem.save
# }
@tickets = Ticket.where(woStatus: ['ARV','CAN','COM','D','H','O','S'])
logger.debug "@tickets size = #{@tickets.size.to_s}"
@tickets.sort_by!{|y| [y.work_order]}.reverse!
@tickets.each {|ticketItem|
logger.debug "#{ticketItem.customer_name.to_s } + #{ticketItem.woDesc.class}"
if @locationHash.has_key?(ticketItem.office)
@locationHash[ticketItem.office] << ticketItem
else
@locationHash[ticketItem.office] = Array.new
@locationHash[ticketItem.office] << ticketItem
end
}
@locationHash.keys.each {|keyItem|
logger.debug "#{keyItem} array size = #{@locationHash[keyItem].size.to_s}"
@locationHash[keyItem].each{|ticketItem|
logger.debug "#{ticketItem.customer_name.to_s } - #{ticketItem.woDesc.class}"
}
}
end
end
create_table "customers", :force => true do |t|
t.string "number"
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "entries", :force => true do |t|
t.string "customer"
t.string "work_order"
t.text "description"
t.string "arrival_time"
t.string "depart_time"
t.integer "day_id"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "timesheet_order"
t.integer "user_id"
t.boolean "submitted"
t.integer "ticket_id"
t.integer "customer_id"
t.integer "type_id"
t.integer "productivityType"
end
create_table "ticket_import", :id => false, :force => true do |t|
t.string "srvStat"
t.string "offId"
t.string "callNbr"
t.string "custName"
t.string "priorityLevel"
t.string "svcDescr"
t.string "techId"
t.string "endDte"
t.string "custNum"
end
create_table "tickets", :force => true do |t|
t.string "work_order"
t.integer "customer_id"
t.datetime "created_at"
t.datetime "updated_at"
t.string "woStatus"
t.string "office"
t.text "woDesc"
t.string "tech"
t.string "entDate"
t.string "customer_name"
end