And you get an error like:
*** extconf.rb failed ***
Go read:
http://blog.bmn.name/2008/02/rails-gem-install-mysql-throws-error-extconfrb-failed
And you get an error like:
*** extconf.rb failed ***
Go read:
http://blog.bmn.name/2008/02/rails-gem-install-mysql-throws-error-extconfrb-failed
If you’re using the above combination, and you’re getting the above error, make sure that you’ve configured Paperclip to find ImageMagick in the right place. Create an initializer file, RAILS_ROOT/config/intializers/paperclip.rb, and put “Paperclip.options[:image_magick_path] = ‘path/to/image_magic’” inside of it. On Mac or a *nix system, type “which identify” to find the right folder.
Big thanks to avit on this forum for the solution.
I haven’t tested this on all “machines” running Snow Leopard, but on the brand new one I had to get today for work, I found that the default Ruby / Gems install doesn’t support installing gems that require building native extensions. The error message I was treated to contained the following:
MacBook-Pro-de-Ethan-Garofolo:~ juanpaco$ sudo gem install thin
Password:
Building native extensions. This could take a while...
ERROR: Error installing thin:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install thin
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/eventmachine-0.12.10 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/eventmachine-0.12.10/ext/gem_make.out
The solution was hyper-intuitive. Install XCode. Because of course that's the first thing you think of.
Hooray for a non-rant post!
The heart of this method works outside of Rails, but there’s one particular convenience method that Rails provides. Find some way to mimic that behavior, and the rest would apply. Also, this is a MySQL-specific solution. I haven’t tried it with any other DB systems.
We “rename” a database by moving all of its tables into a new database. We do so via MySQL’s RENAME TABLE command. Basically, create an empty database with the new name. We then use our ActiveRecord connection’s “tables” method to loop over all the tables in our database, executing a RENAME TABLE from the old to the new with each iteration. “Tables” is the convenience method I mentioned above. Encapsulating this in a method we get:
def rename_database(old_db_name, new_db_name)
ActiveRecord::Base.connection.execute "CREATE DATABASE #{new_db_name}"
ActiveRecord::Base.connection.tables.each do |table|
ActiveRecord::Base.connection.execute
"RENAME TABLE #{old_db_name}.#{table} TO #{new_db_name}.#{table}"
end
ActiveRecord::Base.connection.execute "DROP DATABASE #{old_db_name}"
end
Error checking is left as an (important!) exercise to the reader. Also, you may prefer to monkey patch this into ActiveRecord itself as opposed to some odd method floating around in global space.
This presupposes that the new database destination will be on the same server.
Another way to rename a database is to mysqldump the old one to a file and then reimport it to the renamed database. The method presented in this article is advantageous if your database has a large amount of data. Renaming a table is almost instant. Dumping millions of rows and reimporting them is not so instant.
From http://groups.google.com/group/rubypgh/msg/0489eed858e642a0:
gem environment
Type the above. That is all.