Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show is not working: solution given #48

Open
mateuy-dev opened this issue Oct 1, 2014 · 2 comments
Open

show is not working: solution given #48

mateuy-dev opened this issue Oct 1, 2014 · 2 comments

Comments

@mateuy-dev
Copy link

I'm using Rails 4.1.6 on sqlite3.

On the default (generated) controllers, show operation does not work.

The sql generated is the following:
SELECT "posts".* FROM "posts" WHERE "posts"."id" = ? LIMIT 1 [["id", "84857d86-9700-4bc2-b934-63ffedd76bee"]]
But the working one is:
SELECT "posts".* FROM "posts" WHERE "posts"."id" = ? LIMIT 1 [["id", "\x84\x85}\x86\x97\x00K\xC2\xB94c\xFF\xED\xD7k\xEE"]]

I've solved the problem modifing the set method on the controller, to ensure String is used
def set_post
@post = Post.find(params[:id].to_s)
end

@csavage-mdsol
Copy link

I'm using sqlite and rails 4.1.8, I found that I needed the equivalent of

  @drd = Drd.find(UUIDTools::UUID.parse(params[:id]))

to generate the functioning sql you describe. Have you found an alternative implementation of uuids as primary keys you like? This has me looking.

@mateuy-dev
Copy link
Author

I'm using postgresql and its UUIDs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants