content top

Rails Beginner: Mac OSX, Macports, RVM, MySQL 5.1 – Y U No Work?

Just for the sake of remembering:
After installing MySQL via Macports (which installs mySQL to a different place than you’d expect), install the MySQL gem with:

sudo env ARCHFLAGS=”-arch i386″ gem install mysql — –with-mysql-config=/opt/local/bin/mysql_config5

I finally remembered after I found my bookmark for Mark Turner (amerine.net)’s post on installing Rails 3/Ruby 1.9.2.

Read More

Rails Beginner: Interesting technologies based on/around Ruby on Rails

While learning Rails, I’ve come across a fair number of really interesting subsets/addons to Rails. This is a list of the ones I plan to investigate in greater detail:

  • Sinatra – Super simple and quick rails app setup – it doesn’t get much easier than this:

    require ‘sinatra’

    get ‘/’ do
    “Hello World!”
    end

    I love the way Sinatra does routing, and the erb :erbname syntax just makes sense right off the bat. Also is supposed to work well with heroku, though I haven’t goten that far yet.

  • Refinery – Also super-quick and easy Gem, but builds out a bare-bones but extensible CMS/blogging engine. COWPU and Bend.rb are using it during the weekly hack night in Bend to build hot sexy pizza websites.
  • Coffeescript – Coffeescript is a kind of Ruby-ish language that compiles into javascript, and as of Rails 3.1 will come bundled with rails. I like coffeescript because I’m a dork who can’t type and I always mess up javascript, which is then just a PITA to debug.

Read More

Beginner Rails: Heroku

Heroku is pretty cool: a free host for your rails apps that also works really well with git/github. Since my current hosting has some pretty odd hosting for rails, I’ll be using heroku to host my demo apps. While adding a demo app, I received this error:

heroku keys:add …/custom_require.rb:36:in `require’: no such file to load — readline (LoadError)

According to dirk.net, this error is due to missing libraries after installing ruby from source.

The provided fix worked just fine for me:

sudo apt-get install libncurses5-dev
sudo apt-get install libreadline5-dev

After that, I cd to where I unpacked the Ruby source and ran:

ruby extconf.rb
make
sudo make install

heroku keys:add worked fine from there. Thanks to dirk.net for the fix.

Read More

Beginner Rails: Ruby on Rails on Ubuntu 10.04

In my quest to get ruby on rails up and running on all three OSes tat live in my house (windows, mac OSX leopard, linux), I ran into a snag in the install process on Ubuntu 10.04.

Ruby v 1.8.7 was alive and well, however, following the steps at rubyonrails.org, when I tried to update gem:
sudo gem install rails
OR
sudo gem update –system
I received this error:

/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require’:
no such file to load — zlib (LoadError)

Oddly enough, I received the same error when trying to create a rails app or start the rails server – even though rails *seemed* to be installed. Mysterious!
I had previously installed ruby via the synaptic package manager, gotten the same message, then tried again via sudo apt-get install ruby-full build-essential, none of which had relieved the issue.
So, searching the googlenet, I came across this post:
http://thoughtsincomputation.com/posts/ubuntu-and-ruby-191-zlib-missing
He had run into the same issue, and noted that the actual missing library was called zlib1g. I checked synaptic, and I had that installed – but, he noted that he had compiled Ruby from source, which I hadn’t tried. So, following his instructions:
sudo apt-get install zlib1g-dev

I then went to http://www.ruby-lang.org/en/downloads/ and got the source for version 1.9.2 (since this was the version I’m currently running on windows). I compiled ruby1.9.2 from source, and the problem was resolved.

Read More

Beginner Rails: Installing and running ruby on rails on Windows 7 64-bit

Notes for myself on learning rails

I set up rails using:
http://rubyonrails.org/download
Everything below here deals with the Windows install – since Tomcat on linux is causing me problems, I’m using windows right now so I can switch between jsp/servlets/php/rails more easily.

After initial setup, I always received this error:

Could not find gem ‘sqlite3 (>= 0)’ in any of the gem sources listed in
your Gemfile.

Eventually Google gave me this solution, which is to specify WHICH sqlite3 gem to use:

gem ‘sqlite3-ruby’, ’1.3.2′, :require => ‘sqlite3′

After which, I ran bundle install and everything went fine.
This is in total contrast to trying to run rails using mysql – both version 1.8.7 and 1.9.2 seem to only want to use mysql2, even after specifying in the Gemfile and in config/database.yaml to use mysql. I would always get this:

Could not find gem ‘sqlite3 (>= 0)’ in any of the gem sources listed in
your Gemfile.

Eventually I worked around this by downloading an older version of the libmySQL.dll (when I find the link I’ll update this) and putting that directly into the Ruby/bin dir. Not a great workaround. An actual ‘fix’ for this seems to be described on this page:
http://rorguide.blogspot.com/2011/03/installing-mysql2-gem-on-ruby-192-and.html – however, this solution is only for a full install of the mysql server on your machine. I use WAMP for PHP dev, so I decided rather than remembering to stop and start WAMP mysql ten times a day, I would just use this workaround:

First, install the DevKit from here:
http://rubyinstaller.org/downloads – make sure to read the docs first.

Then, update the Gemfile in your rails app:
gem ‘mysql2′, ’2.8.1′

Run bundle install.

run rake db:migrate (after rails generate to generate the models. More on this later.)

Following this tutorial:
http://ruby.railstutorial.org/chapters/beginning#top

Notes:
While using the github client for windows, always use git bash. Half of the time, commands work from the windows cmd prompt, but the other half they don’t.
ex: c:\Ruby\rails\first_app>git push origin master
error: src refspec master does not match any.
error: failed to push some refs to ‘git@github.com:jgbarr/first_app.git’

While using git bash remember to cd to the correct directory! After 1st setup (on windows 7), you’ll be in your home directory, where the .ssh dir was created.
Using the git client for windows was pretty painless, so long as I remembered to do things correctly. I ended up with this (github profile: http://github.com/jgbarr/):
https://github.com/jgbarr/first_app

Read More
content top