Rails 3 – Beta – no such file to load — rails/cli (LoadError)

27. April 2010

When trying to create a rails project you might encounter the following error:

/Users/jfischer/.rvm/gems/ruby-1.9.1-p378/gems/rails-3.0.0.beta3/bin/rails:1:in `require’: no such file to load — rails/cli (LoadError)
from /Users/jfischer/.rvm/gems/ruby-1.9.1-p378/gems/rails-3.0.0.beta3/bin/rails:1:in `<top (required)>’
from /Users/jfischer/.rvm/gems/ruby-1.9.1-p378/bin/rails:19:in `load’
from /Users/jfischer/.rvm/gems/ruby-1.9.1-p378/bin/rails:19:in `<main>’

The problem can be solved by uninstalling all prior rails and active* beta versions using the gem command:

gem uninstall railties actionpack actionmailer activemodel activeresource activerecord activesupport

Then reinstall rails:

gem install rails --prerelease --no-ri --no-rdoc

Rails3 – Beta – No such file or directory – lib

27. April 2010

If you encounter an error like the following when trying to install rails 3 prerelease:

ravel:~ jfischer$ gem install rails --prerelease

Successfully installed rails-3.0.0.beta3

1 gem installed

Installing ri documentation for rails-3.0.0.beta3...

ERROR:  While executing gem ... (Errno::ENOENT)

No such file or directory - lib

then you might want to try skipping the ri and rdoc generation which worked for me:

ravel:~ jfischer$ gem install rails --prerelease --no-ri --no-rdoc

Successfully installed rails-3.0.0.beta3

1 gem installed

Scottish Ruby Conference 2010 sum up

8. April 2010

Really impressed by the beauty of scottish architecture I was wondering how the Scottish Ruby Conference will be like.It has been held at the Royal College of Physicians in Edinburgh a really impressive location. With a history of more than 300 (!) years it is an organization contrasting the the baby aged computer science fraction.The old library

The contrast of talks delivering bleeding edge content and rooms like the “old library” with the elegance and beauty of centuries made up an extraordinary atmosphere.

It was great to see so many well known faces in Edinburgh. I’ve met friends from many different places such as Berlin, Belgium, and the Netherlands. It’s always a pleasure to hang out with you guys!

The talks have been on a very good level.Beside Jim Weirich’s role playing talk about Rails and the ENTERPRISE (sound like “the Beauty and the Beast”, I Know) I really liked Elise Huard‘s talk “12 hours to rate a rails application“. This talk covered – beside others – how to use code metrics to find code smells, how those metrics work and which social aspect to keep in mind when interviewing the programming team of the app to be evaluated.

Certainly a highlight was the insight view of scottish culture with music a weapon fights. Have a look at scotruby’s flickr photos and see them in action. Awesome!

It was also very nice to hang out with a lot of new people in various situations. I really hope we’ll see next year at the Scottish Ruby Conference 2011!

Accessing the Java Printing API using JRuby

5. April 2010

If you ever have to print a document from a Ruby app you might want to consider using JRuby to access the Java Printing API.Here is a small example accessing the API, looking up the printers and printing out their names to the console:


require 'java'
flavor = javax.print.DocFlavor::INPUT_STREAM::TEXT_PLAIN_HOST

aset = javax.print.attribute.HashPrintRequestAttributeSet.new
aset.add(javax.print.attribute.standard.MediaSizeName::ISO_A4)
aset.add(javax.print.attribute.standard.Copies.new(1))

services = javax.print.PrintServiceLookup.lookupPrintServices(flavor, aset);

puts("Anzahl der Drucker: " + services.length.to_s)

services.each do |service|
puts service.name
end

The output looks like this:

Anzahl der Drucker: 1HP Photosmart 8000 series

Video of the talk about Evolutionary Programming with Ruby

25. Dezember 2009

The video of my Talk about Evolutionary Programming with Ruby at the Ruby en Rails Conference 2009 in Amsterdam ist now online.

ReR09 – Julian Fisher – Evolutionary Algorithms from Interbureau Holder on Vimeo.

RuPy 2009 – Ruby/Python conference in Poznan Poland sum up

20. November 2009

The RuPy conference 2009 was really a great event. I was totally excited how a polish technology conference will look like and I was impressed how the organiziers cared about everything. Among others Jakub P. Nowak, Katarzyna Bylec and Adam Parchimowicz helped with any open questions. They organized a hotel room as well as the transportation from and to the airport. That’s really a great thing for a non-commercial conf!

The conference itself was a hell lot of fun with very good speakers and valuable talks.

I enjoyed hanging around with Charles Nutter aka headius. I am totally impressed by his work for JRuby and his very smart and analytic way of thinking. His talk about JRuby without any slides was very motivating and helped me to find my enthusiasm for live coding sessions.

Another talk that souldn’t be missing on a good conference is Paolo Negri presenting RabbitMQ. I heard his talks before at RailsConf 2009 in Las Vegas and Rails Underground 2009 in London. They are never the same and always worth listening to them. Even multiple times.

Michael Dirolf‘s talk An Introduction to MongoDB was very interesting. I really like MongoDB because it’s a document based DB with a query language that is very easy to understand for people with RDBMS experience. So have a look at it.

And of course don’t miss Eleanor McHugh. Her talk The Ruby Plumber’s Guide to *nix was very contrasting to other talks. She adviced people to remind that web applications are not aliens landed on a unix box but that they are still living in a symbiotic way with it. I think if you have a question about system programming – ask her! Don’t excpect a single sentence answer but be sure you will get a very profound one.

Serge Smetana presented Advanced Performance Optimization of Rails Applications. Badly I was unable to listen to his talk but everybody said it was very, very good. We talked a lot so I am totally sure that he really knows about optimization very well.

I have received a lot positive feedback for my own talk about Ruby and Python Enterprise Hosting as well. Thanks to everybody for that. I still think that people can save a lot of time, nerves and money if they really gather their requirements before diving into the hosting topic. I tried to sum up the most important factors when building a high availability hosting platform. So if you have any questions about this – just let me know.

Enterprise Hosting

View more presentations from Julian Fischer.

Beside the conference content there were a lot of great off topic conversations with many people. I totally liked hanging around with Chares, Michael, Serge, Elenor, Paolo and all the others. Hope to see these friends again, soon. Maybe on the next conf, maybe on the next RuPy?

P.S.: I heard about wedding crashers before. This time I saw my first conference crasher. There was this guy who found (or stolen) a conference batch. He used it to get free food and attended to a number of talks. Instead of beeing calm he talked to nearly every speaker. It turned out that he doesn’t have a clue what Ruby or Python is. At the end of the conf he told one of the organizers that he is actually not a legitimate attende. The orga team told him they will call the police. I saw the ANGST in his eyes :-) Mabe that’s what he needed after behaving very very odd and unpolite in many situations. However he was another fun factory for the conf!

So we’ll see next year at the RuPy?

Hibernate – No CurrentSessionContext configured

20. November 2009

If you encounter an error like:

org.hibernate.HibernateException: No CurrentSessionContext configured!

you probably want to add this line to your hibernate.cfg.xml

<property name="hibernate.current_session_context_class">thread</property>

Ruby en Rails 2009 Conference in Amsterdam

3. November 2009

This year’s Ruby en Rails conference in Amsterdam was a great success. A lot of great speakers came together with an amazing audience.

Besides the two Rails talks from Jeremy Kemper and  Yehuda Katz there were a lot of really interesting talks.

Jonathan Weiss’ Talk about Rails Security, for instance, was very interesting and should be a must read for all rails people.

The lightning talks about DataMapper and MongoDB were also very good and I am totally looking forward to play around with these technologies.

I was wondering whether a off-topic like my talk about genetic algorithms in Ruby will be popular but surprisingly I received much positive feedback. Thank all you guys!

The code of my talk solving the traveling salesmen problem with genetic algorithms can be found on avarteq’s github account.

Slides are on slideshare.net:

Finally, many thanks to Chris and Tim Obdam who organized this outstanding conference. Hope to see you next year again!

RTeX::Document::GenerationError with Phusion Passenger

17. September 2009

In a recent project I experienced a RTeX::Document::GenerationError only when using Phusion Passenger. After a closer look I’ve seen that the PDF has been successfully created but the redirect to the following request failed. Everything works fine with mongrel.

However, the error messaged looked like the following:

RTeX::Document::GenerationError in BillsController#index</h3> <pre>Could not find result PDF document.pdf after generation.

[...]

In this case the Rails app renders a bill and sends it via email to the customer and then redirects back to the bill listing. The error does not occur during the bill generation. The email including the pdf will be send successfully.

The error happens in the redirection to bills_path. The latex log document.log show that Rails or RTex has rendered html as it should but then passed it to RTex to render a pdf from html (instead of tex).

Workaround

In order to prevent this behaviour I studied the gem and found the following workaround. After generating the PDF simply put

Thread.current[:_rendering_rtex] = false

before the redirect. The RTeX::Document::GenerationError should be gone.

Free Ruby – Email2sms – E-Mail to SMS Gateway

29. August 2009

Avarteq GmbH

Email2sms has been developed by www.avarteq.de.

Email2sms is a free and pure Ruby E-Mail to sms gateway including an extensible filterchain to filter and manipulate incoming emails before sending them as text messages.

Requirements

In order to run Email2sms you will need the following.

Required gems

  • developergarden_sdk
  • tmail

Installation

If it is the first time you install a gem from github you might need to perform the following command:

gem sources -a http://gems.github.com

Also have a lookt at gems.github.com for a brief introduction on how to install gems hosted by GitHub.

In order to install the actual email2sms gem invoke the following command:

gem install avarteq-email2sms

Configuration

The first time you start email2smd it will create the following directory:

ENV["HOME"]/.email2sms

Which basically means that it will create the hidden directory email2sms in your home directory (~/).

In addition to this it will create a configuration file template:

~/.email2sms/email2sms.yml

Now it’s you turn:

Open the config file and adapt it to your needs.

Usage

The basic usage of email2sms is straight forward. It’s mainly about starting and stopping the daemon.
Type

email2smsd -h

to get more information. This help is generated by the daemon gem so this message is not application specific but it will give you to get a short introduction about how to control the daemon.

Start

email2smd start

Stop

email2smsd stop

Watch output in

email2sms_main.rb.output

and

 email2sms_main.rb.log

for detailed application state information and errors.

The files are located in the folder you have configured in your configuration file.
By default this is the directory from where you have started the daemon.

Send e-mail

Ok, now you are ready:

In order to send an sms just send an email to the email adress configured in the email2sms.yml file.
If you use the subject filter then you will need to have the password in your subject line:

Subject:
mypass +49177 12344567
Message body:
Whatever

That’s it. Have fun!

Download @ GitHub