0

I'm writing a Ruby program to manage courses run at a university, the modules associated with those courses, and the students registered on the courses and modules. I'm using RubyMine to write the program, and I now want to connect what I've written so far to an SQLite database to check that it works as I expect. But I'm not too sure how to do this in RubyMine.

I've opened the database tool window, and it says "No data sources configured", as well as having two "loading" messages at the top of the window.

If I right click on the window, I get a few options, one of which says "Add data source", from which I can add a "DB data source", or a "DDL data source".

I've only ever written one Ruby program before (about 10 months to a year ago), and I used the command line to write it then, also using the command line to create and edit the SQLite database. How can I set up an SQLite database to run with my program from RubyMine?

Also, is there a huge difference between SQLite and SQLite 3? Are there reasons for using one over the other? Which one would people recommend I use?

EDIT 24/08/2012 at 13:50

I tried selecting the option "Run rake tast" from the 'Tools' menu in RubyMine- it then asked me to enter task name or its part, I tried entering "db:migrate", but it said "no matches found".

Any idea what I should do instead?

Someone2088
  • 141
  • 2
  • 7
  • 16

1 Answers1

2

Please refer to the documentation, RubyMine connects to the database via the JDBC driver. Most likely you want to use SQLite 3 version, as it's the current version at the moment. Check this video for the overview of the Data Sources features.

To connect your program to the database you don't need JDBC driver, it can be done with the sqlite3-ruby gem.

You can also consider some ORM, like Rails ActiveRecord or DataMapper, or Sequel.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
  • For some reason I'm unable to run a rake test from the Tools menu- any idea why? – Someone2088 Aug 24 '12 at 13:04
  • Make sure you have a Rails project. – CrazyCoder Aug 24 '12 at 21:15
  • Ah, ok I thought that's what I had, but I've just tried creating a new Rails project, and that seems different to what I've got, so that must be what the problem was- thanks! – Someone2088 Aug 25 '12 at 14:33
  • The file structure in the Rails project is quite different to what I previously had- if I was to copy my .rb files into the Rails project, which folder should I put them in? The two classes I have so far are Application.rb (which is the one that the user will have interact with mostly), and CourseModules.rb (which will mainly be writing user input in the database) – Someone2088 Aug 25 '12 at 14:39