I'm experiencing what I believe is an environment issue, but I'm at my end as far as debugging it. I'm attempting to connect to a Sybase SqlAnywhere from a Rails 3.2.13 app on the same network. This is working from a rails 2.8 app, but I desperately need to upgrade.
It seems that I can connect through the rails console to the database the very first time that I create my new ruby gem and gemset using RVM, but subsequent attempts simply hang with no response after an attempt to query the database. I believe the database connection is being established as I get an error when incorrect credentials are supplied. After a successful connection on the first attempt, I am unable to replicate the success by opening a new terminal tab, setting the same gem and gemset, sourcing the database, and issuing the same query in the rails console.
I'm using a rails32 branch of a fork of the sqlanywhere adapter since the database adapter hasn't been supported by Sybase for a little while, but it has reported success using the same setup and I don't think this is the root of my issue since I've successfully returned valid data in the trials with limited success.
I've compared the working and non-working environments with no apparent difference, but is there anything significantly different about the RVM environment after the initialization of the gem/gemset that could be getting in the way?
Related
I have a Rails app on a windows machine that also has a SQLServer that it used to use as it's database.
However I am trying to transition the app to use a new SQL server on a different Windows machine.
The new Machine is reachable (ping)
After changing the database.yml file with the new IP I can go into Rails console and make queries on the new machine.
However, Running the code still queries the local(old) database.
I have restarted apache.
This is driving me nuts. Why is my code still hitting the old configuration? Do I need to restart the machine completely?
Thanks
Just Try printing the TARGET_ENV and the URI that you are targeting in the Ruby code. It will tell you which IP is being hit everytime.
I've researched this for a few hours now and I can't seem to find a solution.
I have a Rails 2 app that uses the TinyTds gem ( tiny_tds ) to connect to an SQL 2000 server hosted locally in our company.
The app has been connecting to SQL Server almost every day for the past 6 months with no problem.
Suddenly, when trying to connect yesterday, I started getting an error:
TinyTds::Error: Unable to open socket
from /var/lib/gems/1.8/gems/tiny_tds-0.4.5/lib/tiny_tds/client.rb:60:in `connect'
from /var/lib/gems/1.8/gems/tiny_tds-0.4.5/lib/tiny_tds/client.rb:60:in `initialize'
From my research, I've seen some people suggesting that I use
SO_REUSEADDR to allow it to connect and ignore timeout or "usage" restrictions, like this:
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR)
but I cannot figure out how to use that command within the current context.
I tried calling it in commmandline on the server and it won't work, but then again, I'm not sure what it does or if I can even call that from commandline.
I've tried calling
netstat -a
which shows current sockets, but I'm not sure what to do with that information.
I've also seen that
service restart
can restart a socket, but I'm not sure which socket to restart.
Lastly, in my freetds.conf configuration file, I have these settings:
host = 192.168.0.220
port = 1433
tds version = 8.0
I'm not really sure which road to take. I'm comfortable with Rails but this socket stuff is way outside my current understanding. This is also a Rails 2 app ( legacy ) which is key to some core processes our business uses. We can't upgrade to Rails 3 due to SQL server adapter gem for SQL 2000 Server won't work with Rails 3.
Can anyone help ?
I'm coming from the PHP/MySQL world, trying to set up a Rails/PostgreSQL app. It doesn't seem to want to connect and I'm having a hard time pinning down the cause of the problem. Are there certain troubleshooting steps I can take to figure out what's going wrong?
Update: the problem is not with PostgreSQL. I can connect to PostgreSQL via the command line, remotely via an IDE, and via a PHP script. I just can't seem to connect to it through this Rails app.
First I'd start with the actual database.yml file to make sure i have all the right user and password information.
I'd also make sure i ran whatever it is you do to make postgres start it's server, so that connections can be established. (Whether you use a psql start or it starts when you start your dev env. So only you can answer that one).
Is the database created?
Can i connect through console? rails console shouldn't give an error.
Do you have the correct postgres gem installed and is that in your bundle file (or environment.rb file)?
This has been addressed some time ago, but I've not had any luck following the steps outlined or advice suggested. Here's my situation:
I've installed SQL Server '05 and have another (non-Ruby) application utilizing it successfully.
I've got Rails up and running successfully (but only for MySQL.)
I've installed the Rails sqlserver adapter gem (as well as its dependencies.)
I've downloaded ADO.rb (now only available on older builds of Ruby-DBI) and placed it into c:\ruby\lib\ruby\site_ruby\1.8\DBD\ADO\ADO.rb.
I've configured database.yml to use the sqlserver adapter and pointed it towards my database with valid login information.
When I attempt to run a migration, I get the ugly 'Unable to load driver ADO (uninitialized constant DBI::DBD::ADO)' error.
Thanks immensely for any assistance.
So just make sure if you're working on Windows or Mac to set up an ODBC connection. You must indicate this explicitly in your database configuration for Rails.
I am using rails freeze 1.2.3 to run a rails app. Because the app is on a remote machine, I used ssh tunnel (ssh -l -L) to show the app on my screen. When I ran it, it correctly prompted the login page, after I put in the info, I got this error:
OCIError in ServiceController
Error while trying to retrieve text for error ORA-12154
I have tried the same app on a different machine w/o using freeze (because that machine has rails version 1.2.3 while current one has 2.0.2). Is that where the error comes from?
Thanks.
That's an Oracle error. It sounds like your database setup is incorrect. Put the error number ORA-12154 in Google and you'll find some useful stuff.
ORA-12154 is a classic. As Sarah points out its nothing to do with your Rails or Ruby per se. ORA-12154 is generated when the Oracle Client can't connect to the oracle server. So most likely your setup is wrong in:
Your database.yml, if you can connect using tnsping or sqlplus (Oracle client utils) you probably just need to look at this.
Your Oracle networking setup, particularly your tnsnames.ora file (found in $ORACLE_HOME/network/admin if I remember correctly). This may need some extra help from a friendly DBA as the tnsnames.ora syntax has quirks. Check this link link text for more info.
Hope that helps.