If you’re using RVM and attempting to setup a fresh server, do not forget to do the following
$ rvm package install readline
$ rvm package install zlib
$ rvm remove 1.9.2
$ rvm install 1.9.2
Seemed to solve most open issues for me.
Also, you need to system install somedev libraries. For instance I needed to run the following because bundle install failed:
sudo apt-get install libsqlite3-dev, libreadline5-dev, libncurses5-dev
That last statement btw – solves most problems with RVM and readlines. After that you can follow the directions on beginrescueend around readline
.
In order to maintain different versions of Ruby, Rails and Gems on your machine, nothing works better than RVM.
Ruby Version Manager also allows for different versions of rails, and gems, and you can switch simply by throwing in
rvm system
Or to create a different ruby/rails environment follow Wayne’s Gist here, reproduced below for posterity.
This example shows how to setup an environment running Rails 3 under 1.9.2 with a ‘rails3′ gem set.
∴ rvm update --head
# ((Open a new shell)) or do 'rvm reload'
# If you do not already have the ruby interpreter installed, install it:
∴ rvm install 1.9.2
# Switch to 1.9.2-head and gemset rails3, create if it doesn't exist.
∴ rvm --create use 1.9.2@rails3
# Install Rails 3 final
∴ gem install rails
# Check to see we now have Rails 3
∴ rails --version
Rails 3.0.0
After you create a rails app, remember to run bundle install – and you’ll have all the necessary gems as part of the appropriate rvm version.
If you experience this error while installing the latest version fo Rails 3.0.7 as of this date.
ERROR: While generating documentation for rails-3.0.7
... MESSAGE: exit
... RDOC args: --ri --op /usr/lib/ruby/gems/1.8/doc/rails-3.0.7/ri lib --title rails-3.0.7 Documentation --quiet
It’s because you are likely to be on ruby 1.8.7. Upgrading to 1.9.2 seems to solve this problem.
That being said, it doesn’t seem to hamper Rails in anyway.
For those of you that are involved in scraping via Ruby etc. that require the use of RegEx’s a great site that will be useful is Rubular.
One of the little tricks I discovered today was the use of the ?: in the regular expression.
I’m sure this is old news to most people, but since it was useful to me, maybe it is of use to someone else.
In Ruby, lets say I’m scraping a page, using the scan operator, and if there’s a <H2> I want to grab it, and if there’s an <H3> I want to grab it, and I want to ignore anything inside a <p>. Well, I can make the H2 optional, by placing it in brackets, and throwing a ? after it like so
/<H2>.*<\/H2>/mi
However, now I have the problem of cleaning the gathered data of the H2′s etc. An easier way is this -
/(?:<h2(.*?)<\/h2>)?(?:<H3(.*?)<\/H3>)?(?:<p.*?>)?/mi
If you want to interact with another web-service on the inter-webs as we know it, sooner or later you will find the need to make a SOAP call using Ruby.
Today I ran into such a need.
I looked at a few things already out there that could do it, but for the most part, it was overkill.
So I tried to figure out how to roll my own, and this is what I found ::
Read more…
If you attempt to
gem install mysql
and run into errors that look like this…
Read more…
Quick note about the latest version of facebooker (as of July 31st 2009)
If you see an error that looks like
/home/brickfactor/facebooker_tutorial/vendor/plugins/facebooker/lib/facebooker
/adapters/adapter_base.rb:43:in `load_adapter': Facebooker::AdapterBase::UnableToLoadAdapter (Facebooker::AdapterBase::UnableToLoadAdapter)
/RAILS_APP/vendor/plugins/facebooker/lib/facebooker/adapters/adapter_base.rb:43:in `load_adapter': Facebooker::AdapterBase::UnableToLoadAdapter (Facebooker::AdapterBase::UnableToLoadAdapter)
from /RAILS_APP/vendor/plugins/facebooker/lib/facebooker.rb:121:in `load_adapter'
from /RAILS_APP/vendor/plugins/facebooker/lib/facebooker.rb:65:in `apply_configuration'
from /RAILS_APP/vendor/plugins/facebooker/lib/facebooker.rb:45:in `load_configuration'
from /RAILS_APP/vendor/plugins/facebooker/rails/../init.rb:6
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in `require'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
... 16 levels...
from /usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/generate.rb:1
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
Its because you haven’t configured config/facebooker.yml file correctly, or at all. (Most tutorials etc. have you creating and editing this file after you install facebooker)
Make sure you fill in all the details in the file, and you should see the error no more.