So in my Rails models I'm doing the following to generate an "SEO friendly" slug:
def to_param
"#{id}-#{title.parameterize}"
end
So that generates something like: example.com/items/1-example-title
But when I check my logs, the SQL calls are then:
SELECT * FROM `items` WHERE (`items`.`id` = '1-example-title') LIMIT 1
That seems to work fine for MySQL, but PostgreSQL flips out on it.
So, how can I get my SQL query to just use 1
for the id
instead of the full slug?