0

I upgraded my app from Rails 3.2 to Rails 4.1, but now it's unable to display individual Answers. When I go to the show page for an answer (like '/answers/0183759926'), I get an error:

PG::InvalidTextRepresentation: ERROR: invalid input syntax for integer: "--- {} " LINE 1: ... "answers" WHERE "answers"."id" IN (1862, '--- {} ^ SELECT "answers".* FROM "answers" WHERE "answers"."id" IN (1862, '--- {} ') ORDER BY answers.updated_at DESC 

I have a model called Answers:

 class Answer < ActiveRecord::Base #... default_scope { order('answers.updated_at DESC') } obfuscate_id #... 

This is the controller:

def show @answer = Answer.find(params[:id]) #relies on gem end 

I'm using the gem 'obfuscate_id' to scramble the displayed ID:

 gem 'obfuscate_id', :git => 'https://github.com/namick/obfuscate_id.git' 

How do I fix the error?

Update:
This seems to be an issue with the gem's find method. See https://github.com/namick/obfuscate_id/issues/19

2
  • If you find the answer yourself, you should submit it as an answer instead of updating the question. Commented Apr 11, 2014 at 21:42
  • @intgr, ok, added an answer. Commented Apr 13, 2014 at 1:36

1 Answer 1

1

This issue is caused by a incompatibility between the current gem and Rails 4.1. To circumvent it, I called Answer.deobfuscate_id to get the actual id, and then used find_by(id: ) on the actual id.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.