Archiv der Kategorie ‘Ruby on Rails‘

Ruby (on Rails) – Wirble – Pimp my IRB and Console

Montag, den 20. Juli 2009

Ever wanted a colored irb or script/console? Well, you should try wirble. It gives you a number of enhancements for Irb. Some of the features are: Tab completion Colorized results … Installation is easy as pie:  sudo gem install wirble vi .irbrc require ‘rubygems’ require ‘wirble’ # start wirble (with color) Wirble.init Wirble.colorize

Ruby on Rails 2.3 – Nested Attributes with AJAX support

Sonntag, den 12. Juli 2009

Introduced in Rails 2.3 nested attributes help to shorten code if you want to edit multiple nested models within a single form. Here the corresponding article from the rails weblog: http://weblog.rubyonrails.org/2009/1/26/nested-model-forms There is also a very good tutorial on nested forms from Ryan Daigle: http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes Right now it seems as if there is no clean [...]

Rails 2.3 – Test Unit – undefined method `fixtures’ (NoMethodError) – undefined method `fixtures’

Donnerstag, den 9. Juli 2009

After switching to Rails 2.3 you might receive the following error messages while executing your TestUnit tests: undefined method `fixtures’ (NoMethodError) and/org undefined method `fixtures’ The solution to this is to change the class in test/test_helper.rb from Test::Unit::TestCase to ActiveRecord::TestCase. You will need to apply this change to all Tests inheriting for the  Test::Unit::TestCase class.

Ruby – Test::Unit – Invoke a single test from the command line

Mittwoch, den 24. Juni 2009

Sometimes you don’t want to execute your while test suite but only a single test of it. Actually this is easy as pie. Just append –name and the name of the test method. ruby your_test.rb –name test_new_call_a_doesn_pick_up That’s it.

Curb and curl: (1) Protocol https not supported or disabled in libcurl

Sonntag, den 21. Juni 2009

If you receive an error message like the following from either curb or curl: curl: (1) Protocol https not supported or disabled in libcurl Then you might want to recompile curl with ssl support. If you are a Mac OS X user and you are using MacPorts this might look like this: sudo port install [...]

Rails – collection_select statt select für ein belongs_to Drop-Down

Montag, den 18. Mai 2009

Oft hat man in Rails-Anwendungen 1:n Beziehungen und möchte den belongs_to Partner, hier im Beispiel der BillingContact, aus einer Liste betreffender Kandidaten auswählen. @contacts = BillingContact.all Oft zu sehen sind Konstrukte wie: f.select(:billing_contact_id, @contacts.collect{ |ch| [ch.name, ch.id] }) Das funktioniert. Es geht aber auch etwas leichter: f.collection_select( :billing_contact_id, @contacts, :id, :name ) Natürlich könnten noch [...]

Ruby on Rails 2.3 Features – ActiveRecord scoped_by

Samstag, den 9. Mai 2009

Ein interessantes neues Feature in Rails 2.3 ist die scoped_by Methode von ActiveRecord-Objekten. Stellen wir uns ein einfaches ActiveRecord-Model Page mit den Attributen title und content vor und betrachten folgende Anweisung: Page.scoped_by_title(“a”).count => 3 Das resultierende SQL zeigt, dass ein COUNT Statement verwendet wurde, d.h. die Generierung des SQLs erfolgt nicht nach dem Aufruf von [...]

Passenger (mod_rails) jetzt (v2.1.1) mit Solaris und OpenSolaris-Support

Montag, den 9. März 2009

Die Installation von Ruby on Rails mit Phusion Passenger unter OpenSolaris kann mit der kommenden Version 2.1.1 nun mit der offiziellen Passenger Version erfolgen. Wie im Beitrag phusion-passenger-modrails-unter-opensolaris-200811 beschrieben, war es vorher nicht möglich Passenger, zumindest nicht ohne Modifikation des Quellcodes, unter OpenSolaris zu kompilieren. Den Verlautbarungen des Phusion Blogs zufolge wird mit dem kommenden [...]

Ruby on Rails mit Phusion Passenger unter OpenSolaris

Montag, den 9. März 2009

Von all den Tutorials, die die Installation von Ruby on Rails unter Solaris oder OpenSolaris beschreiben, laß sich das folgende HowTo am angenehmsten: http://blog.hendrikvolkmer.de/2009/1/29/deploying-a-rails-application-on-opensolaris-with-passenger-aka-modrails Vorrangiges Qualitätsmerkmal ist die möglichst weitgehende  Verwendung des OpenSolaris-Paketmanagers pkg. Andere Tutorials greifen hier nur allzu oft zu früh zu Quellcode und Kompiler.

Sqlite und Sqlite Gem unter OpenSolaris installieren

Samstag, den 7. März 2009

Um Sqlite unter OpenSolaris zu installieren, kann der Solaris-Paketmanager verwendet werden: pkg install SUNWsqlite3 Das Sqlite-GEM installiert man dann wie folgt: gem install sqlite3-ruby