Tuesday, January 5th, 2010

Using Flexigrid with MySQL field carriage returns

Problem
You want to use flexigrid with a MySQL fields that contains carriage returns. As the flexigrid uses json it doesn’t work with carriage returns, and displays an empty page, instead of an error page.
Solution
In the page_name.json.erb file in the fields that has carriage returns make sure that you use to_json method as in the [...]

No Comments » - Posted in MySQL, ruby on rails by kosmas

Wednesday, April 29th, 2009

Mandriva – Rails 2.3.2 – mysql gem – ‘ERROR: Error installing mysql’

Problem
You are trying to install the mysql gem in Mandriva, but it fails with error messages:
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension…
checking for mysql_query() in -lmysclient… no ….
Solution
After searching in google, with solutions about providing different options (– –with-mysql-config, ..etc), even trying different combinations for providing the client library path, the [...]

No Comments » - Posted in Mandriva, MySQL, linux, ruby on rails by kosmas

Monday, February 16th, 2009

Comparing data from two big MySQL tables

Problem
You have two big tables in MySQL (>640K records), that maybe differ in the number of fields, but you want to make sure that the data in the common fields in both tables are the same.
Solution

Use mysql to export the data from the first table in a csv file, selecting only the common fields.
We use [...]

No Comments » - Posted in MySQL, linux by kosmas

Monday, April 21st, 2008

Converting Paradox tables to MySQL sql in Linux

Problem
You want to convert some legacy tables created in Paradox (.db, .px) to another format so you can use it in MySQL.
Solution
Download the px tools from here.
Follow the instructions, in the INSTALL file after you untar the file.
You should have to do the usual three step linux installation:
configure
make
sudo make install
Afterwards to make sure that the [...]

No Comments » - Posted in linux by kosmas

Wednesday, October 17th, 2007

File column plugin with ActiveScaffold upload branch

When using the file_column plugin in the active_scaffold upload branch, the documentation in the file_column doesn’t make it clear what we have to change to make it work.
In the example below the model is number and the file_column is intro.
1. In models/number.rb add:
file_column :intro
2. in controllers/numbers_controller.rb, make sure we have:
config.create.multipart = true
config.update.multipart = true
3. in [...]

1 Comment » - Posted in ruby on rails by admin

Wednesday, October 17th, 2007

Get a random record in Ruby on Rails – MySQL

To get a random record from MySQL in Ruby on Rails use:
User.find(:all, rder => ‘rand()’)

No Comments » - Posted in ruby on rails by admin