0

Railsクエリからそのような記号、、を回避@new_recordするfalse方法@readonly

ハッシュの私の結果はそのように示されています

[#<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]

そして、同じクエリが再び起動したときに取得します。最初は正常に機能しますが、2回目からは異なるタイプのシンボルを取得します, , のよう@new_recordfalse@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
4

0 に答える 0