Tuesday, October 13, 2009

Setting MySQL permissions for a Rails project

Enter mysql as root:
  • mysql -u root -p
Grant permissions for each dev, test, & prod databases:
  • GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON rails_project_development.* TO 'username'@'localhost' IDENTIFIED BY 'password';
  • GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON rails_project_test.* TO 'username'@'localhost' IDENTIFIED BY 'password';
  • GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON rails_project_production.* TO 'username'@'localhost' IDENTIFIED BY 'password';

Labels: ,

Wednesday, April 29, 2009

Installing Rails on Ubuntu 9.04

Just installed Ubuntu 9.04 (released Apr 23, 2009) on my work laptop. Here are all the things I needed to do to get a Rails environment working. One additional complication is that I use Heroku to deploy. Install non-default Ubuntu packages
  • mysql-client & mysql-server
  • ruby
  • git, svn, cvs, & integration with git (git-svn, git-cvs)
  • sun-jdk 6 (for eclipse)
  • lynx, wget, curl
Install RubyGems Once the base ruby package is installed, all the rest of the ruby/rails stuff is installed via sudo and tar.gz download. In this case,
  • download the latest Ruby Gems tarball from http://rubygems.org/
  • untar
  • cd into the directory
  • run: ruby setup.rb
  • make a symbolic link to gem1.8: cd /usr/bin; sudo ln -s gem1.8 gem
Install Rails
  • sudo gem install rails
Install Heroku
  • sudo gem install heroku
If this error results, then install ruby1.8-dev
  • sudo apt-get install ruby1.8-dev
Running Heroku Running heroku for the first time will probably get an error because libopenssl_ruby isn't installed
  • sudo apt-get install libopenssl-ruby
Creating a MySQL database via rake Invoking "rake db:create" in the new Rails app directory will probably get this error: "sudo gem install mysql" will cause another set of errors. That's because libmysqlclient5-dev is not installed. I tried installing it on the command line via "sudo apt-get install libmysqlclient5-dev" but that didn't work. However, the Synaptic Package Manager did the right thing.
  • sudo gem install mongrel
Lastly, if the mongrel gem is not installed, then running rails will fire up WebBrick.
  • sudo gem install sqlite3-ruby
causes this error: The fix is to install libsqlite3-dev
  • sudo apt-get install libsqlite3-dev
and that should allow sqlite3-ruby to install properly.

Labels: , , ,