Tag: sql server 2005

从Windows将rails应用程序连接到SQL Server 2005

我(遗憾地)必须在Windows XP上部署一个必须连接到Microsoft SQL Server 2005的rails应用程序。 在网上冲浪有很多从Linux到SQL Server连接的点击,但无法从Windows中找到如何做到这一点。 基本上我遵循以下步骤: 安装dbi gem 安装activerecord-sql-server-adapter gem 我的database.yml现在看起来像这样: development: adapter: sqlserver mode: odbc dsn: test_dj host: HOSTNAME\SQLEXPRESS database: test_dj username: guest password: guest 但我无法连接它。 当我运行rake db:migrate时,我得到了 IM002 (0) [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified 我不是Windows用户,因此无法理解dsn元素的含义。 有人知道如何解决这个问题吗? 提前致谢 现在我已经将Alexander.yml修改为: development: adapter: sqlserver mode: odbc […]

如何validation主键?

我无法validationTransaction_Id ,这是我的事务表的主键,而我可以使用email 。 什么似乎是问题? 救命。 谢谢。 这是我的模特/交易: def self.authenticate(email, transaction_id) user = Transaction.find_by_email(email) if user && user.Transaction_Id return user else return false end end 这是我的控制器/修改: def attempt_login user = Transaction.authenticate(params[:email], params[:Transaction_Id]) if user session[:user_id] = user.id session[:email] = user.email flash[:notice] = “You are now logged in!” redirect_to :action => “modify” else flash[:notice] = “Invalid username/password […]