Archive for 'Database'

Incorrect MySQL client library version! This gem was compiled for 5.6.21 but the client library is 10.0.14-MariaDB

If you get the following error, you probably have to reinstall your mysql2 gem by specifying the location of your MariaDB or MySQL installation. The Error: Uninstall existing mysql2 gem: Install mysql2 gem again: If you still see issues: Here is the error you might see: Uninstall existing mysql2 gem: Install mysql2 gem again: The […]

Having issues installing gem ‘pg’ (postgresql)?

If you run into the “Can’t find the ‘libpq-fe.h header” error, see below if you want to know how I solved the problem: I was able to solve the problem by executing the following before doing a ‘bundle install’:

Unable to Open Couchbase Admin Console (could not connect to 127.0.0.1:8091)

I downloaded and installed the 64-bit Mac OS X version of Couchbase 2.0.0 Release but I got a “could not connect to 127.0.0.1:8091” in the browser when I tried to open the Couchbase Admin Console to open up the installer/configurator. The problem is that the first time I tried to fire up Couchbase was when the […]

Installing PostgreSQL on a mac (Lion)

Check to see if you mac already has an older version of PostgreSQL installed: postgres –version which postgres If you see anything, that means you already have an older version of postgres installed. Install PostgreSQL via Home Brew: brew install postgresql Somewhere in the output after PostgreSQL is installed you’ll see the version of your […]

Bundle Install – missing mysql.h

If you’re seeing the following error: The way I was able to resolve it was to follow Boonedocks.net, since I’m also using MAMP for its MySQL Database instance. The only difference is that I already had MAMP 1.9.4 installed and so I had to download the MAMP_components_1.9.dmg which contains the mysql-5.1.44 source code. MAMP 1.9.4 […]

Using lambda with named scopes in Rails 3

You can define an ActiveRelation named scope inside your model Address, for example, like so:

ActiveRecord destroy method

Once you destroy a record, the object becomes frozen. Call the frozen? method on the referenced object before and after calling destroy to see the difference. If you try to manipulate the object after the object is ‘frozen’, you’ll get a TypeError: can’t modify frozen hash

Installing, Configuring and Troubleshooting PostgreSQL 9.0 in Rails 3 on OS X

The following may apply to other versions of PostgreSQL as well but I’m using version 9.0. I initially tried to install PostgreSQL via MacPorts but after running into issues I describe below, I ended up installing it via the Mac OS X package. If you want to skip issues I ran into with my macports […]

Handling 404s when RecordNotFound, UnknownAction and RoutingError

When handling 404s, you want to display the 404 page and return HTTP status 404 when a particular record is not found, the action requested is unknown or if there is a routing error. Add the following to your application_controller.rb file, towards the end:

SET data type in MySQL and ActiveRecord

I figured out something cool which solves a common database design problem. However, I’m not sure if this is supported in ActiveRecord since the SET data type does not exist in all databases. Let’s say each record in a table has zero or more properties and your set of properties is pre-defined. How would you […]