如何避免这样的符号@new_record
, false
,@readonly
来自 rails 查询
我的哈希结果是这样的
[#<Hotel id: 42, hotel_name: "Vijay: Resort De Alturas,Candolim", stars: "4", location: "North Goa", created_at: "2013-09-21 20:05:25", updated_at: "2013-09-21 20:05:25", searchable: true>, :@readonly, false]
并且当相同的查询再次触发时它会得到,第一次它工作正常,但从第二次得到不同类型的符号,比如@new_record
,,false
@readonly
我的查询是
@hotels = Hotel.sort_hotel_by_price(session["search"],price_type)
def self.sort_hotel_by_price(hotels,price_sort_type=nil)
pkg_prices_in_sort_order=[]
# hotels.reject!{|h| h.to_s.chr=="@" or h==false}
pkg_prices_in_sort_order << (hotels.map{|hotel| hotel.package_prices.order("price ASC").first})
pkg_prices_in_sort_order.flatten!
pkg_prices_in_sort_order.reject!{|pkg_price| pkg_price.nil?}
pkg_prices_in_sort_order = pkg_prices_in_sort_order.sort{|x,y| x["price"]<=>y["price"]}
if (price_sort_type=="high")
pkg_prices_in_sort_order.reverse!
end
sort_hotels=[]
sort_hotels << (pkg_prices_in_sort_order.map{|s| s.hotel})
sort_hotels.flatten!
end