norman/friendly_id — Issue #214: Does friendly_id work with sql server as the backend for rails ?
Author: amitagit
Created: 2012-01-17 06:18:57+00:00
State: open

Is there some configuration change needed to make friendly_id work with sql server and tiny_tds?

I am using friendly_id 4.0.0 rails 3.0.1 and tiny_tds 0.2.3 (because I have a sql server database as a backend for the rails application)

This stackoverflow query has the details:
http://stackoverflow.com/questions/8875135/friendly-id-does-not-work-with-sql-server-and-tiny-tds

I am getting the following error while trying to create a new record from console:
ActiveRecord::StatementInvalid: TinyTds::Error: 'LENGTH' is not a recognized built-in function name

This is because SQL Server does not have the LENGTH function, but is has a LEN function.

So the query on line 48 in slug_generator.rb is causing the problem.

Also the find_each(&:save) does not update the slug for existing records even if I change the line in slug_generator.rb to make it LEN instead of LENGTH. However making this change in slug_generator.rb successfully creates a new record with the slug from rails console.