Activerecord-jdbc-adapter replace_limit_offset mssql error

Hi,

This is the first time I use mssql, configuration is as follows:

Gemfile

gem ‘rails’, ‘3.2.12’

gem ‘jdbc-jtds’, ‘~> 1.2.7’
gem ‘activerecord-jdbcmssql-adapter’, ‘1.2.7’

config/database.yml

development:
adapter: mssql
username: dan
password: dan
host: vmhost
instance: SQLExpress
database: strs_web

I’m not able to run rake db:create, but if I create db manually then I
can run db:migrate to create my tables.

After migration “Environment.create” works just fine, but
“Environment.first” throws an “ActiveRecord::JDBCError: Table
environments) does not exist”, see attached log file.

Investigating this further… when I run

SELECT t.* FROM (SELECT ROW_NUMBER() OVER(ORDER BY [environments].id) AS
_row_num, [environments].* FROM [environments]) AS t WHERE t._row_num
BETWEEN 1 AND 1

from Sql Management Studio then I get the same error. Yet If I
execute"use strs_web;" before I try the select query then I get the
result I’m expecting.

My question are

  • Why don’t I get this error run “Environment.all.to_a”?
  • How to solve this?

Thanks
-Dan