DevHeads.net

Active Record

I'm trying to develop a small database application using Ruby 2.3.1, the
gem activerecord-5.0.0.1 (part of the Ruby package), and the sql3 database
system that comes with the Mac (I don't want to use Rails, only active
record).

The beginning of the program goes like this:

require 'sqlite3'
require 'active_record'

db_config = {
'adapter' => 'sqlite3',
'database' => 'test.db'
}

ActiveRecord::Base.establish_connection(db_config)

In RubyMine, I get all kinds of warning that don't mean much to me, and I'm
not going anywhere.

Question: How do I put together a simple database project only using Ruby,
Active Record, and sql3? (I've read everything I could online already, so
please don't tell me to google it).

Comments

Re: Active Record

By Hassan Schroeder at 08/12/2017 - 20:27

On Sat, Aug 12, 2017 at 5:32 PM, Marc Chanliau <marc. ... at gmail dot com> wrote:
Well, yeah, absolutely agree -- you're not going anywhere by saying
"Help, I have a problem but I won't tell you what it is"

Re: Active Record

By Raj Sahae at 08/12/2017 - 21:25

What is the error you are getting? That's generally the 2nd thing you want
to provide.

On Sat, Aug 12, 2017, 6:27 PM Hassan Schroeder <hassan. ... at gmail dot com>
wrote:

Re: Active Record

By Marc Chanliau at 08/13/2017 - 00:10

Raj, the error I was getting was that sqlite3 was not found. I realized the
gem was not installed. I installed it and "required" it, but I still get
the error. Anyway, no sweat, I'll find out.

BTW, I thought this list was supposed to be helpful. Next time I'll post to
stack overflow to avoid the arrogance of some around here.

Re: Active Record

By Hassan Schroeder at 08/13/2017 - 08:43

If posting a vague open-ended question without a reproducible code
example *and exact error messages* on Stack Overflow gets you
better results, go for it.

It's "arrogance" to post a request for help to a mailing list of thousands
of people without providing real information to enable them to help.

See also: <a href="http://www.catb.org/esr/faqs/smart-questions.html" title="http://www.catb.org/esr/faqs/smart-questions.html">http://www.catb.org/esr/faqs/smart-questions.html</a>

P.S. For the record, the snippet you posted had no errors -- I used it,
verbatim, to connect to a Sqlite3 DB using Active Record...

Good luck,

Re: Active Record

By Alexander Patrick at 08/13/2017 - 00:34

Marc,

Try running the file from the command line to make sure it's not an issue
with RubyMine.

If the issue persists, run `gem list | grep sqlite3` to make sure its
install was successful.

Finally, please consider pasting the error messages verbatim into your
emails or into your Stack Overflow questions. It's very difficult to help
you otherwise.

Best,
Alex

On Sun, Aug 13, 2017 at 8:10 AM, Marc Chanliau <marc. ... at gmail dot com>
wrote: