Ruby on Rails Auto complete

# view
Just a little test:
<%= text_field_with_auto_complete :contact, :name %>
 
# controller
auto_complete_for :contact, :name

Zwei(!) Zeilen im Zweifelsfall. Unglaublich. Jaw dropper.

Wer mehr dazu wissen möchte:

Das ganze basiert Clientseitig übrigens auf script.aculo.us

| Comments (4) »

11-Jan-07


Ruby On Rails native MySQL Bindings Vs. RMagick

I’m writing this post in english in hope that more people find it useful…

Some times ago i really had bad problems installing the MySQL Gem 2.7 with Ruby 1.8.2 or 1.8.5 in conjunction with Rails 1.1.6 on Mac OS X 10.4

Compilation failed with:

Building native extensions. This could take a while…
mysql.c: In function ‘Init_mysql’:
mysql.c:2015: error: ‘ulong’ undeclared (first use in this function)
mysql.c:2015: error: (Each undeclared identifier is reported only once
mysql.c:2015: error: for each function it appears in.)
mysql.c:2015: error: parse error before numeric constant
mysql.c:2018: error: parse error before numeric constant
make: *** [mysql.o] Error 1
mysql.c: In function ‘Init_mysql’:
mysql.c:2015: error: ‘ulong’ undeclared (first use in this function)
mysql.c:2015: error: (Each undeclared identifier is reported only once
mysql.c:2015: error: for each function it appears in.)
mysql.c:2015: error: parse error before numeric constant
mysql.c:2018: error: parse error before numeric constant
make: *** [mysql.o] Error 1
ruby extconf.rb install mysql — –with-mysql-dir=/usr/local/mysql
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lm… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lz… yes
checking for mysql_query() in -lmysqlclient… yes
checking for mysql_ssl_set()yes
checking for mysql.h… yes
creating Makefile

The gem would then install with Successfully installed mysql-2.7. Creepy!!! But that damn thing just didn’t work.

After quite some googling i found this one:

Running Rails on OS X with MySQL 5.0.24

It’s all about puting a little

#ifndef ulong 
#define ulong unsigned long
#endif

somewhere in “/usr/include/stdlib.h”.

This tipp is still necessary for MySQL 5.0.24+. Thanks again mate!!

But here the trouble starts….

I put the define in a nice little conditional just in case but bah… It would come down to hunt me…

For my project DailyFratze.de i also need RMagick. Again, the gem (1.14.1, 1.14.0 and 1.13) failed to compile but didn’t tell (on runtime it said “require “RMagick” LoadError: No such file to load — RMagick.so” … ) and installation from source did fail as well with:

setup.rb:655:in `command': system("make") failed (RuntimeError)
from setup.rb:664:in `make'
from setup.rb:1258:in `setup_dir_ext'
from setup.rb:1532:in `__send__'
from setup.rb:1532:in `traverse'
from setup.rb:1530:in `dive_into'
from setup.rb:1530:in `traverse'
from setup.rb:1534:in `traverse'
from setup.rb:1533:in `each'
... 8 levels...
from setup.rb:826:in `__send__'
from setup.rb:826:in `invoke'
from setup.rb:772:in `invoke'
from setup.rb:1578
make: *** [all] Error 1

Damn! After banging my head against the walls, reinstalling ImageMagick and all it’s depencies either direct from source, via i-installer and finally as mentioned here i took a break, visited some porn sites and stuff like that and though, hmm… stdlib.h….

I removed the little define and bam! It’s that easy, RMagick compiles just fine…

From the forums i found i guess other people with the same error message may have the same problem as i had…

I really wish installing a ruby on rails environment would be a less pain in the ass…. somewhere near as easy as developing with rails.

| Comments (2) »

02-Jan-07


Eine handvoll iTunes Tipps

Da ich gerade ein Mac OS X neu aufgesetzt habe, ist mal wieder nichts so, wie ich es gewohnt bin. Deswegen zuerst im iTunes die Bedeutung der Pfeile neben Album und Künstlernamen umstellen. Standardmäßig zeigen die nämlich in den iTMS. Das find ich aber ziemlich unnütz.

Mit folgenden Befehl

defaults write com.apple.iTunes invertStoreLinks -bool YES

springen sie in die Musikbibliothek. Wird der Pfeil z.B. neben “Queen” gedrückt, so werden danach alle Titel von Queen angezeigt.
Das ursprüngliche Verhalten erreicht man, wenn man die Wahltaste dabei gedrückt hält.

Rückgängig macht man das durch

defaults write com.apple.iTunes invertStoreLinks -bool NO

Dann habe ich mir auch wieder mein geliebtes Synergy installiert, eine kleine Apple iTunes Fernsteuerung, die zusammen mit Growl iTunes perfekt steuert und den aktuellen Titel wunderhübsch im Musikvideostil anzeigt.
Jedenfalls, worauf ich hinaus will: In einer der letzten Versionen hat Synergy auch gelernt, mit Last.FM umzugehen. Ergo: Man kann sich den unsäglichen neuen Last.FM Player sparen, wenn man dort einen Account hat. Sehr praktisch.

| Comments (1) »

27-Dec-06


Safe Sleep: Sicherer Ruhezustand

Anläßlich dieses Ereignisses bestand Grund nach den Einstellungen für den Ruhezustand von Mac Rechnern zu gucken. Ich weiß nicht mehr bei welcher Generation, aber kurz vor der Intelumstellung konnten die neuen PowerBooks das und mit einem kleinen Hack auch die ältere Generation.

Mit den neuen Mac Books ist das kein Problem. Hier hilft pmset weiter:

sudo pmset -a hibernatemode x

x steht dabei für folgende Optionen:

  1. Die alte Sleep-Variante, in der das RAM über Akku oder Netzadapter mit Strom versorgt wird.
  2. Hier wird das RAM auf die Festplatte gesichert und der Laptop heruntergefahren.
  3. Der Standard-Modus neuerer Laptops vereint Modus 0 und zur Sicherheit Modus 1.
  4. Dieser funktioniert wie Modus 1, aber ist für sicheres virtuelles RAM gedacht, welches in den Sicherheitseinstellungen aktiviert werden kann.
  5. Dieser funktioniert wie Modus 3, ist aber ebenfalls für sicheres virtuelles RAM gedacht.

Klar ist es prima, wenn das Notebook schnell wieder aufwacht, allerdings ist es meines Erachtens praktischer, wenn im Ruhezustand der Akku nicht belastet wird.

Meine Erfahrung mit Safe Sleep: Es funktioniert absolut stabil. Selbst auf älteren Macs ist es mir noch nicht passiert, dass sie nicht mehr aufgewacht sind, im Gegensatz zu vielen PCs.

| Comments (0) »

17-Dec-06