sql - ActionView::Template::Error (PG::UndefinedFunction: ERROR: operator does not exist: integer ~~ unknown -
i switched mysql postgresql utilize in heroku. search not work. can't figure out wrong operator. actionview::template::error (pg::undefinedfunction: error: operator not exist: integer ~~ unknown.
2014-11-11t19:59:58.082607+00:00 app[web.1]: processing alllistingscontroller#search_listings js 2014-11-11t19:59:58.105074+00:00 app[web.1]: 4: <% @listings.each |listing| %> 2014-11-11t19:59:58.102205+00:00 app[web.1]: ^ 2014-11-11t19:59:58.105066+00:00 app[web.1]: hint: no operator matches given name , argument type(s). might need add together explicit type casts. 2014-11-11t19:59:58.105083+00:00 app[web.1]: app/controllers/all_listings_controller.rb:14:in `search_listings' 2014-11-11t19:59:58.110318+00:00 heroku[router]: at=info method=get path="/search_listings?q=500&_=1415735994648" host=subleasy.herokuapp.com request_id=24a21078-d3fd-4bce-9afb-bfc9d976c0a7 fwd="50.247.32.153" dyno=web.1 connect=1ms service=35ms status=500 bytes=1754 2014-11-11t19:59:58.103449+00:00 app[web.1]: completed 500 internal server error in 21ms 2014-11-11t19:59:58.102207+00:00 app[web.1]: hint: no operator matches given name , argument type(s). might need add together explicit type casts. 2014-11-11t19:59:58.105076+00:00 app[web.1]: 5: $("div.search_list").append("<%= escape_javascript(render('all_listings/listings_partial', a_listing: listing )) %>") 2014-11-11t19:59:58.105073+00:00 app[web.1]: 3: 2014-11-11t19:59:58.103270+00:00 app[web.1]: rendered all_listings/search_listings.js.erb (5.1ms) 2014-11-11t19:59:58.105071+00:00 app[web.1]: 2: $("div.search_list").html("") 2014-11-11t19:59:58.105081+00:00 app[web.1]: app/views/all_listings/search_listings.js.erb:4:in `_app_views_all_listings_search_listings_js_erb___729824412217144086_70218143810320' 2014-11-11t19:59:58.102209+00:00 app[web.1]: : select "listings".* "listings" (rent '%500%' or city '%500%' or state '%500%' or address '%500%') order rent asc limit 5 offset 0 2014-11-11t19:59:58.105078+00:00 app[web.1]: 6: <% end %> 2014-11-11t19:59:58.102199+00:00 app[web.1]: pg::undefinedfunction: error: operator not exist: integer ~~ unknown 2014-11-11t19:59:58.105068+00:00 app[web.1]: : select "listings".* "listings" (rent '%500%' or city '%500%' or state '%500%' or address '%500%') order rent asc limit 5 offset 0): 2014-11-11t19:59:58.105084+00:00 app[web.1]: 2014-11-11t19:59:58.082630+00:00 app[web.1]: parameters: {"q"=>"500", "_"=>"1415735994648"} 2014-11-11t19:59:58.105058+00:00 app[web.1]: 2014-11-11t19:59:58.105061+00:00 app[web.1]: actionview::template::error (pg::undefinedfunction: error: operator not exist: integer ~~ unknown 2014-11-11t19:59:58.105063+00:00 app[web.1]: line 1: select "listings".* "listings" (rent '%500... 2014-11-11t19:59:58.105065+00:00 app[web.1]: ^ 2014-11-11t19:59:58.077155+00:00 app[web.1]: started "/search_listings?q=500&_=1415735994648" 50.247.32.153 @ 2014-11-11 19:59:58 +0000 2014-11-11t19:59:58.102203+00:00 app[web.1]: line 1: select "listings".* "listings" (rent '%500... 2014-11-11t19:59:58.105070+00:00 app[web.1]: 1: 2014-11-11t19:59:58.105085+00:00 app[web.1]: 2014-11-11t19:59:58.105079+00:00 app[web.1]: 7: $(".hidetable").hide()
my method
def search_listings @listings = listing.where("rent ? or city ? or state ? or address ?", "%#{params[:q]}%", "%#{params[:q]}%", "%#{params[:q]}%", "%#{params[:q]}%").order(sort_column + " " + sort_direction).paginate(:per_page => 5, :page => params[:page]) respond_to |format| format.js end end def sort_column listing.column_names.include?(params[:sort]) ? params[:sort] : "rent" end def sort_direction %w[asc desc].include?(params[:direction]) ? params[:direction] : "asc" end
schema.rb
create_table "listings", force: true |t| t.integer "user_id" t.string "address" t.string "city" t.string "state" t.date "lease_start" t.string "lease_length" t.string "lease_type" t.integer "rooms" t.text "description" t.string "email" t.string "phone" t.integer "rent" t.integer "zipcode" t.datetime "created_at" t.datetime "updated_at" t.string "photo_file_name" t.string "photo_content_type" t.integer "photo_file_size" t.datetime "photo_updated_at" t.float "latitude", limit: 24 t.float "longitude", limit: 24 end
why won't work in postgresql when works flawlessly in mysql???
it seems trying utilize like
operator on integer
column (namely rent
). don't believe work (at to the lowest degree in postgres).
according answers here might want seek add together cast:
@listings = listing.where("cast(rent text) ? or city ? or state ? or address ?", ...
sql ruby-on-rails ruby postgresql heroku
No comments:
Post a Comment