Wednesday February 13, 2008
TOTD #26: Overriding Database Defaults in Rails 2.0.2
A Rails 2.0.2 application configures SQLite3 database by default. This requires you to have SQLlite3 database running and also have the corresponding database adapter installed. Even this is part of the Leopard (Mac OS 10.5+) development kit but this needs extra configuration on non-Leopard machines.
One of the guiding principles of Rails is Convention-over-Configuration. So there are couple of ways you can override this default:
jruby -S rails -d mysql myappconfig/environment.rb"
and adding the line:config.frameworks -= [ :active_record ]environment.rb"
and remove other frameworks from inside the parentheses.Please leave suggestions on other TOTD that you'd like to see. A complete archive is available here.
Posted by Arun Gupta in web2.0 | Comments[5]
|
|
|
|
|
Today's Page Hits: 771
Total # blog entries: 994
| « November 2009 | ||||||
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
1 | 2 | 4 | 6 | 7 | ||
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | |||||
| Today | ||||||
Are we going to get Sqlite3 support in JRuby anytime soon?
Posted by Alex MacCaw on February 13, 2008 at 12:55 AM PST #
I have few questions? I hope you can answer them. Maybe this is not the WRITE section but....
why is market drifting towards .net? dot net or java?
instead of supporting ruby, why cant sun make java and tools easier? ANT what is that for? progammer shuld only write business logic not an ANT script.
why struts, hibernate, spring, shale? JSF but industry still moans about Struts.
is open source really helping?
WHY IS THERE NO COMPLETE STANDARD
Posted by Chirdeep on February 13, 2008 at 11:22 AM PST #
Alex,
Would you be interested in working on it ? :)
The shortest path would be to use one of the sqlite jdbc drivers out there. But it will probably be difficult to get working out of the box because the sqlite adapter that's in Rails itself will take precedence.
Posted by Arun Gupta on February 14, 2008 at 05:56 PM PST #
You said:
"This requires you to have SQLlite3 database running"
Ummm, there is no such thing. You imply that sqlite3 is a running process. It is not. It is simply a file on the filesystem that gets created automatically by the first call to the DB.
Do you often find you are creating rails apps that don't use a database? Can you give an example? Plain Ruby apps I can understand, but I think there are very few (none) rails apps that make no use of a DB.
You said:
"But it will probably be difficult to get working out of the box because the sqlite adapter that's in Rails itself will take precedence"
There is no sqlite3 adapter built into rails AFAIK. It is simply a standard Ruby gem library that comes pre-installed on OS X and many other systems and is independant of Rails. It is really an add on component of Ruby that Rails makes use of. If you can install the compiled sqlite3 lib and the sqlite3-ruby gem, you are good to go.
The point of all this is to create a simple default setup that is generally easier to configure and get running than mysql is when starting initial development (e.g. there is no separate step to create the db, it is autocreated). I don't think there are any/many in the rails community that would suggest running a production app on sqlite3 though. Rails migrations make the process of switching eventually from sqlite3 to mysql (or any other Rails supported DB) trivial (just change the name of the database adapter in database.yml and re-run the migrations).
This was kind of a useless and factually incorrect article (even with its tiny bit of actual content) IMHO. It seems you are targeting first-day developers, but then seek to confuse them by throwing in gratuitous references to Sun's work on jruby as if thats the default. This approach would seem to only further confuse any developer that actually needed this ultra basic level of article. I have nothing against JRuby at all but I think this article just sought to add one more link on the web that links JRuby and Rails in a Google search. That seems kind of cynical to me. Target users and not search engines.
Sorry, I hope the next try is better. I'd love for Sun to be active in this community and post real (as in useful) information and code.
Posted by gr on February 16, 2008 at 11:24 AM PST #
Posted by Arun Gupta's Blog on July 01, 2008 at 06:25 AM PDT #