Justin Williams
2007-Dec-17 18:11 UTC
script/console connection works, but Rails app fails with SQL Server
Greetings, I have an application that connects to a remote SQL Server database using DBI/ODBC. If I run the application via the Rails console, I am able to retrieve data and work with the database just fine. If, however I try to access it via the Web application itself, I get the following error: DBI::DatabaseError (S1000 (0) [unixODBC][FreeTDS][SQL Server]Unable to connect to data source): /usr/lib/site_ruby/1.8/DBD/ODBC/ODBC.rb:95:in `connect'' /usr/lib/site_ruby/1.8/dbi.rb:424:in `connect'' /usr/lib/site_ruby/1.8/dbi.rb:215:in `connect'' ... Does anyone have any ideas why this would be the case? I''ve run out of things to try myself, so any help would be appreciated. Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Justin Williams
2007-Dec-17 21:00 UTC
Re: script/console connection works, but Rails app fails with SQL Server
To follow up on this one for the googlers, adding this as an initializer to my project seems to fix it. if ENV[''RAILS_ENV''] == ''production'' ENV[''ODBCINI''] = "/etc/odbc.ini" ENV[''ODBCSYSINI''] = "/etc" ENV[''FREETDSCONF''] = "/etc/freetds/freetds.conf" end The problem is that mongrel_cluster is started as root and then spawns mongrels as deploy- but doesn''t load environment variables --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---