Rails and MySQL woes

Hi,

I'm new to Rails and can't seem to get it working with MySQL.

I am running Ruby 1.9.3, Rails 3.1.3, and MySQL 5.5.17 (windows 7 64bit).

I create the most basic rails project (rails generate demo index, uncomment the last line of the routs.rb file), run the sever and navigate to page and get:

ActiveRecord::ConnectionNotEstablished

ActiveRecord::ConnectionNotEstablished

Rails.root: C:/Users/sdeese/Desktop/RailsPractice/RailsApplication6/RailsApplication6 Application Trace | Framework Trace | Full Trace

Request

Parameters:

None

Show session dump

Show env dump Response

Headers:

None

Can anyone help me?

thanks

Some questions:

Have you setup the database name username and password in database.yml?

Have you created the database rake db:create and run the migrations (if any) rake db:migrate

Are you able to access the database using whatever mysql interface is available for windows?

Note that rails expects there to be a database even if you have not got any tables in it yet.

Colin

Colin Law wrote in post #1035428:

Minus a few thumb-fingered mis-types and sanity checks:

521 rvm install ruby-1.9.3-preview1 522 rvm use 1.9.3 523 rvm gemset create 3.1.3 524 rvm use 1.9.3@3.1.3 526 gem install rails -v=3.1.3 528 rails new swamp -d mysql 529 cd swamp 535 vi config/database.yml 536 rake db:create 540 rails g resource thing name:string age:integer 541 rake db:migrate 544 vi app/controllers/things_controller.rb 546 vi app/views/things/index.html.erb 547 rails s

...and... lights! camera! action!

mysqld Ver 5.1.41 for apple-darwin9.5.0 on i386 (MySQL Community Server (GPL))

Apparently it *does* work. And maybe if you responded to the specific questions already posed by Colin Law, we could help you past whatever is not working in your environment.

Just sayin' ...

yes, but sweeping declarative statements are never going to be a good starting point for taking advice :-/

Stephen, how about modifying your assertion thus, which may be a better place to start reflection:

"The bottom line is that I can't get the latest version of Ruby, Rails, and MySql running on Windows"

PS in your OP, you say: "I create the most basic rails project (rails generate demo index, uncomment the last line of the routs.rb [sic] file), run the sever and navigate to page and get:"

...but you don't mention in that list any changes you made to the database.yml file.

Neither if using the MySQL command line client does indeed connect.

Without knowing if MySQL *works* we are just guessing any possible cause.

Michael Pavling wrote in post #1035507:

The bottom line is that the latest version of Ruby, Rails, and MySql do not work together.

Apparently it *does* work.

Just sayin' ...

yes, but sweeping declarative statements are never going to be a good starting point for taking advice :-/

Stephen, how about modifying your assertion thus, which may be a better place to start reflection:

"The bottom line is that I can't get the latest version of Ruby, Rails, and MySql running on Windows"

PS in your OP, you say: "I create the most basic rails project (rails generate demo index, uncomment the last line of the routs.rb [sic] file), run the sever and navigate to page and get:"

...but you don't mention in that list any changes you made to the database.yml file.

I appologize and agree. It was the end of two full days of frustrations and I should have been more polite to those who were taking their valuable time to try and help me.

I am new to the world of Rails and began by installing all the latest versions of things: Ruby 1.9.3, Rails 3.1.3, and MySQL 5.5.17 (Windows 7 64 bit).

I did a few tutoritals using SQLite and it is indeed very nice. However, I know that I will need to use Rails with MySQL for production, therefore I need to go ahead and get used to it while learning.

Coming from the C#/Silverlight development world where things are highly integrated and just work, I'm finding that the promise that Ruby on Rails is fast and fun to be untrue(and I know this will bring much flack.. but its true). I asked my colleque (a very experienced developer as well) to try to do a "hello world" application in rails using MySQL.. after many many hours of installing, reinstalling, reading blogs, etc.. no bananana. Honestly, I find that very disappoining.

I will try the detailed advice above (thank you for it) and let you guys know what happens. If i get it working, I will put up a detailed article on a blog so as to save the next poor newbie. However, the fact that it is necessary is truly sad. It is what I hate about open source.

One of the issues is that you are using Windows. Most rails developers use Linux (often Ubuntu) or Mac. I understand that generally life is trickier with rails in Windows. I use Ubuntu and have had few such problems. In addition most here do not have experience with Windows so there are not so many who can offer advice. If you have to use windows then I gather that railsinstaller is the way to go. My advice, though, would be to move to Linux or Mac if at all possible. Others may not agree.

Colin

I appologize and agree. It was the end of two full days of frustrations and I should have been more polite to those who were taking their valuable time to try and help me.

I am new to the world of Rails and began by installing all the latest versions of things: Ruby 1.9.3, Rails 3.1.3, and MySQL 5.5.17 (Windows 7 64 bit).

I did a few tutoritals using SQLite and it is indeed very nice. However, I know that I will need to use Rails with MySQL for production, therefore I need to go ahead and get used to it while learning.

Coming from the C#/Silverlight development world where things are highly integrated and just work, I'm finding that the promise that Ruby on Rails is fast and fun to be untrue(and I know this will bring much flack.. but its true). I asked my colleque (a very experienced developer as well) to try to do a "hello world" application in rails using MySQL.. after many many hours of installing, reinstalling, reading blogs, etc.. no bananana. Honestly, I find that very disappoining.

I will try the detailed advice above (thank you for it) and let you guys know what happens. If i get it working, I will put up a detailed article on a blog so as to save the next poor newbie. However, the fact that it is necessary is truly sad. It is what I hate about open source.

Latest version is on 3.1; possibly enough of the prior version on 3.0 still in inventories that if you order from anywhere other than publisher, you might get that.

I am a newbie too and my 2cents. One mistake I did when trying out mysql was in database.yml, I was using mysql driver, but you should mention the driver as "mysql2". I hope u are already doing this.

Update:

After 3 days of shear struggle, I got the following combination to work together:

1. Ruby 1.9.2 2. Rails 3.1.1 3. MySql 5.5.17 (64 bit) 4. Windows 7 64 bit

After reading tons and tons of blogs with advice that didn't work (but Thank you to those on here who tried.. for some reason the blogs here were more helpful).. and almost getting to the same place as this guy.. whose post I copy below:

I’ve been trying to have Rails work with MySQL for 2 days now with no positive result. I followed numerous guidelines and read kilobytes of forum threads. All in vain.

Ruby 1.9.2 + Rails 3.1.1 + MySQL 5.5 on 64bit Win7 is Mission Impossible.

--- AND ---

No, above instructions did not help.

I’m not wasting any more time on this Ruby crap. Enough is enough.

I feel I have to point out that the issues appear mostly to do with mysql and ruby rather than rails. Did you try railsinstaller which I am led to believe is the easiest way to get rails (and ruby etc) going on Windows?

Colin

Re: MicroSoft Windows, Ruby, and Ruby on Rails (RoR)

I formerly did a lot of offline development in Rails on a Windows XPpro system. I started out using pre-packaged native MS-Win binaries but eventually ran into a situation where the available Windows package simply did not work following a MicroSoft service pack 'upgrade' and the package authors could not agree on what was wrong or how to fix it.

At that juncture I switched to Cygwin (http://www.cygwin.com/) and stopped fighting against the RoR OSX/Linux based paradigm. If you are planning on a lot of RoR development on an MS-Win platform and you wish to work with the current versions of the RoR framework and its many supporting tools then installing Cygwin and working within its shell on MS-Win will make your life as a developer considerably less frustrating. Once you have your software working inside Cygwin then you can concern yourself with obtaining the minimal number of native MS-Win ports required to just run the product when distributed. That is a lot easier to accomplish than building and maintaining a complete development environment with native MS-Win binaries.

By the way, switching platforms to BSD/Linux/OSX often means trading one form of frustration for another. The unspoken assumption made by the adviser when such advice is given is that the recipient will undertake to discover any deficiencies in their particular distribution of BSD/Linux/OSX, acquire the missing bits, and then build those bits themselves. That process can present a very steep learning curve to somebody that just wants their development software to work. Just finding the appropriate package repositories (yum, apt, mac-ports, etc.) for your specific distribution can sometimes pose a major hurdle. Cygwin presents somewhat the same difficulty of course but, as it is both the repository (via setup.exe) and the environment (via the shell), it is the only additional thing that you need learn on your Windows host.

Just a few thoughts for your consideration.

Re: MicroSoft Windows, Ruby, and Ruby on Rails (RoR)

I formerly did a lot of offline development in Rails on a Windows XPpro system. I started out using pre-packaged native MS-Win binaries

Just cleansing myself from a few months of RoR on WindowsXP.

At that juncture I switched to Cygwin (http://www.cygwin.com/) and

Cygwin presented some frustrations also. I use Cygwin for somethings, but run cmd and native RoR for others. Really drove me notes having to work in that environment when I have experience in OSX & Linux.

By the way, switching platforms to BSD/Linux/OSX often means trading one form of frustration for another.

True, and someone with no *nix experience would probably want to jump out a window (no pun intended) if they had to adopt that on top of the RoR learning curve.

It *IS* much better though. Being able to just 'sudo apt-get install foo' when you're missing something instead of trying to find, download, install and configure is refreshing.

My solution now is to run Xubuntu on a VirtualBox in my WindowsXp machine. Amazingly, Linux feels fasters in a VM than native WindowsXP.