So, in Rails models, I do the following to create an “SEO-friendly” slug:
def to_param
"#{id}-#{title.parameterize}"
end
This creates something like: example.com/items/1-example-title
But when I check my logs, the SQL calls are as follows:
SELECT * FROM `items` WHERE (`items`.`id` = '1-example-title') LIMIT 1
This seems to work fine for MySQL, but PostgreSQL flips on it.
So, how can I make my SQL query just use 1for idinstead of a full pool?
source
share