No such file to load -- sqlite3 WITH mysql2

Hassan S. wrote in post #964802:

On Mon, Nov 29, 2010 at 8:35 AM, Steve M. [email protected]
wrote:

A bit more of the code - to clarify the origin…

utterly irrrelevant.

:database => ‘db/development.mysql2’)

The line above is wrong – look at your config/database.yml entries
and compare. That is simply not a valid MySQL entry.


Hassan S. ------------------------ [email protected]
twitter: @hassan

Hi Hassan,

The relevance was to show the full title and version number of the book
from which this example code is taken, especially since I know many
others are also reading and following that book and are having similar
problems. Since many consider it the definitive work on Ruby on Rails
then I think it’s worth mentioning it. I agree the actual additional
code shown beyond the comments in the header adds nothing to the problem
analysis. :slight_smile:

I know that line is wrong - Rails tells me that - what I don’t know is
how to fix it, or even why the store.rb file exists at all in the app
folder.

However I downloaded this code from the web site associated with the
book and that’s why it’s in there. The original code from the book uses
sqlite but I prefer mysql and so changed it to use mysql.

Following the book, and creating my own project, I don’t encounter this
problem. But I do encounter a serious problem on “test functionals”
where the db tables are created, seeded, and then promptly dropped prior
to the first test running so all the tests fail. The applicaiton itself
works fine.

So as one particular way of investigating this I decided to download the
code from the book, reconfigure it for mysql, and see if the testing
problem still exists. However I can’t get beyond the db:migrate because
of this problem being explored here.

Unfortunately, although I’ve spent many hours on RoR on both Windows 7
and Ubuntu, the Rails aspects of it are IMHO poorly documented. Ruby
language - yes good documentaiton and I understand that with no problem.
But Rails is unusual in that you can place pieces of an Object in many
places and they all come together at runtime, but if that fails to
integrate properly then you’re pretty much reliant on helpful guys like
yourself online pointing you in the right direction.

I am working my way through…

(a) Agile Web D. with Rails Ed.4
(b) Rails Recipes
(c) RailsSpace: Building a Social Networking Website with Ruby on Rails
(d) Beginning Ruby on Rails E-Commerce

building all of the examples. But in each case I’m encountering problems
and issues.

So if I can solve why “test functionals” keeps dropping the tables
before running the tests then that would be the biggest help.

I realise that test mode is supposed to start with an empty database so
that the tests always run the same. It then creates the tables, then it
seeds them, then for some reason it drops the tables and runs the first
test which failes because the tables don’t exist.

I may be wrong here but I think it used to work before the seeds were
written. That it was after the book covered seeds and the seeds file was
created that this testing problem occured.

It might also have something to do with using mysql with myisam files
because the transaction capability is different according to the Rails
books (although I’ve not noticed that in the past).

Kind Regards
Steve

Steve M. wrote in post #964810:

Colin L. wrote in post #964799:

I seriously suggest considering switching to Ubuntu (or similar). You
would not regret it…

I am doing the tutorials in parallel on Ubuntu. Unfortunately the “test
functionals” issue I mentioned above that started me down this path
occurs there too.

My primary development platform has to be Windows I’m afraid - that’s
what my customers want - but I do as much as possible on Ubuntu as well.
:slight_smile:

Your development environment is no concern of your customers. What do
you mean by “that’s what my customers want”? Why do you think you need
to work on Windows? Remember, you’re developing server-side
applications here that have nothing to do with the client OS.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Hassan S. wrote in post #964823:

On Mon, Nov 29, 2010 at 9:48 AM, Steve M. [email protected]
wrote:

The line above is wrong – look at your config/database.yml entries
and compare. That is simply not a valid MySQL entry.

I know that line is wrong - Rails tells me that - what I don’t know is
how to fix it, or even why the store.rb file exists at all in the app
folder.

And I’ve told you twice how to fix it. Seriously, WTF?


Hassan S. ------------------------ [email protected]
twitter: @hassan

I have followed the advice but it didn’t help…

Database.yml contains entries like:-

development:
adapter: mysql2
encoding: utf8
reconnect: false
database: depot_v_development
pool: 5
username:
password:
host: localhost

which is a database specification broken into multiple elements.

Clearly what is required is a single parameter which specifies the
database, something like, localhost:@/depot_v_development

Unfortunately I don’t know the required syntax and database.yml doesn’t
provide it.

So yes, the advice appears good, but for me it’s incomplete.

If I delete that section of code then the db:migrate works. So now I’m
going to see if everything else still works with it deleted.

I’ll report back.

Marnen Laibow-Koser wrote in post #964825:

Your development environment is no concern of your customers. What do
you mean by “that’s what my customers want”? Why do you think you need
to work on Windows? Remember, you’re developing server-side
applications here that have nothing to do with the client OS.

That’s true for just this one aspect of development. I also use
OutSystems which runs on Windows, .NET which requires Windows, Prolog
which runs best on Windows, and build free-standing apps that target
Windows, I build Fusion:Gen apps where the case tools run on Windows,
and Android apps where the tools that I use are Windows based.

But I guess this is wandering off the point of this thread :slight_smile:

Steve M. wrote in post #964833:

Marnen Laibow-Koser wrote in post #964825:

Your development environment is no concern of your customers. What do
you mean by “that’s what my customers want”? Why do you think you need
to work on Windows? Remember, you’re developing server-side
applications here that have nothing to do with the client OS.

That’s true for just this one aspect of development. I also use
OutSystems which runs on Windows, .NET which requires Windows, Prolog
which runs best on Windows, and build free-standing apps that target
Windows,

Well, Rails runs best on a *nix system. I highly recommend at least a
VM.

I build Fusion:Gen apps where the case tools run on Windows,
and Android apps where the tools that I use are Windows based.

Uh…WTF? Android development is not platform-specific.

Besides, the less you use Windows, the better. If your tools are tying
you to Windows, you really need better tools.

But I guess this is wandering off the point of this thread :slight_smile:

Slightly. But you seem to be under a misapprehension as to how much you
need to use Windows.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Hassan S. wrote in post #964841:

On Mon, Nov 29, 2010 at 10:42 AM, Steve M. [email protected]
wrote:

Clearly what is required is a single parameter which specifies the
database, something like, localhost:@/depot_v_development

Uh, “clearly”? Actually, “clearly” that’s not true – and which would be
quite “clear” if you read the documentation for the method in question:

ActiveRecord::Base.establish_connection

which, at least in the 2.3.8 version I just glanced at, has examples for
both SQLite and MySQL…


Hassan S. ------------------------ [email protected]
twitter: @hassan

OK. My apologies. I didn’t know where to look, but I’ve found it now,
and as you say, it does have an example for MySQL.

Thank you for your patience.

On Mon, Nov 29, 2010 at 10:42 AM, Steve M. [email protected]
wrote:

Clearly what is required is a single parameter which specifies the
database, something like, localhost:@/depot_v_development

Uh, “clearly”? Actually, “clearly” that’s not true – and which would be
quite “clear” if you read the documentation for the method in question:

ActiveRecord::Base.establish_connection

which, at least in the 2.3.8 version I just glanced at, has examples for
both SQLite and MySQL…


Hassan S. ------------------------ [email protected]
twitter: @hassan

On 29 November 2010 17:48, Steve M. [email protected] wrote:

[…]
Following the book, and creating my own project, I don’t encounter this
problem. But I do encounter a serious problem on “test functionals”
where the db tables are created, seeded, and then promptly dropped prior
to the first test running so all the tests fail. The application itself
works fine.

Are you using fixtures? I think most now would advise against
fixtures, suggesting factories instead. See
#158 Factories not Fixtures - RailsCasts for example.
So if you can’t get fixtures to work (or even if you can) then forget
them and move to something better.

Colin

Colin L. wrote in post #964874:

On 29 November 2010 17:48, Steve M. [email protected] wrote:

[…]
Following the book, and creating my own project, I don’t encounter this
problem. But I do encounter a serious problem on “test functionals”
where the db tables are created, seeded, and then promptly dropped prior
to the first test running so all the tests fail. The application itself
works fine.

Are you using fixtures? I think most now would advise against
fixtures, suggesting factories instead. See
#158 Factories not Fixtures - RailsCasts for example.
So if you can’t get fixtures to work (or even if you can) then forget
them and move to something better.

Agreed. Also forget about functional tests and use Cucumber instead.
In fact, forget about Test::Unit and go for RSpec.

The Rails core team made a wonderfully testable framework, but provided
poor testing tools to actually do that testing.

Colin

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

On 29 November 2010 20:58, Steve M. [email protected] wrote:

fixtures, suggesting factories instead. See

I’ll follow the link and see if I can understand how to keep on
following the tutorials but switch to factories. :slight_smile:

The tutorial at http://railstutorial.org/ is good and uses factories
and rspec if I remember correctly. I think you can buy the book or
work through it online for free.

Colin
Colin

Colin L. wrote in post #964874:

On 29 November 2010 17:48, Steve M. [email protected] wrote:

[…]
Following the book, and creating my own project, I don’t encounter this
problem. But I do encounter a serious problem on “test functionals”
where the db tables are created, seeded, and then promptly dropped prior
to the first test running so all the tests fail. The application itself
works fine.

Are you using fixtures? I think most now would advise against
fixtures, suggesting factories instead. See
#158 Factories not Fixtures - RailsCasts for example.
So if you can’t get fixtures to work (or even if you can) then forget
them and move to something better.

Colin

Thanks Colin. I’ll take that on board. Yes, the Agile book’s tutorial
uses fixtures and that’s what I think caused the original problem.
Trouble is, I’m trying to learn Rails and I’m using this book as my
tutor. Can’t run before walking I guess.

I’ll follow the link and see if I can understand how to keep on
following the tutorials but switch to factories. :slight_smile: