undefined method `length’ for Enumerable Enumerator on text_helper.rb:50:in `truncate’
With rails 2.0.2 and ruby 1.8.7 you can find this error using rails truncate helper
To solve this problem, paste this code in your enviroment.rb (eof).
module ActionView
module Helpers
module TextHelper
def truncate(text, length = 30, truncate_string = "...")
if text.nil? then return end
l = length - truncate_string.chars.to_a.size
(text.chars.to_a.size > length ? text.chars.to_a[0...l].join + truncate_string : text).to_s
end
end
end
end
Have a nice day!
How to downgrade rails version on debian
If you want to downgrade rails (aka install an old version of rails) on debian first of all install rails gems. Execute next command as root:
apt-get install rubygems
Remove rails package of debian if it’s actually installed
apt-get remove rails
Now install rails by gems utility and force the right version. Example:
gem install -v=2.0.2 rails --include-dependencies
Now put gems bin folder on bash PATH. Edit /etc/bash.bashrc
export PATH=$PATH:/var/lib/gems/1.8/bin
Note: version of rubygems may be different, check your right PATH to gems bin folder
If all goes right now you can use your preferred rails version. Note, rails command from gems is little different between the script that debian package installs. Just check params: call rails command without params.
$ rails
Usage: /var/lib/gems/1.8/bin/rails /path/to/your/app [options]
Options:
-r, --ruby=path Path to the Ruby binary of your choice (otherwise scripts use env, dispatchers current path).
Default: /usr/bin/ruby1.8
-d, --database=name Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite2/sqlite3).
Default: mysql
-f, --freeze Freeze Rails in vendor/rails from the gems generating the skeleton
Default: false
Rails Info:
-v, --version Show the Rails version number and quit.
-h, --help Show this help message and quit.
General Options:
-p, --pretend Run but do not make any changes.
--force Overwrite files that already exist.
-s, --skip Skip files that already exist.
-q, --quiet Suppress normal output.
-t, --backtrace Debugging: show backtrace on errors.
-c, --svn Modify files with subversion. (Note: svn must be in path)
That’s all folks! 🙂
Intel Corporation PRO/Wireless 4965 AG or AGN (HP notebook dv2690el / Debian / Linux)
Hi! I’m posting to release a fast and furious tutorial to bring your wireless lan active in a few minutes.
I assume that you have a kernel release >= 2.6.24. The iwlwifi driver (we need it) has been merged into mainline kernel since 2.6.24.
Run uname -r command to know your kernel version.
Ex.
$ uname -r
2.6.26-1-686
If your kernel is < 2.6.24, you have to upgrade your kernel.
If your kernel is >= 2.6.24 simply load iwlwifi module with modprobe as root user (to become root user use su command at command line and insert root’s password):
modprobe iwlwifi
Is your wlan led turned blue? It’s right. Your wlan is active.
Now you can configure it with ifconfig or you can create an adeguate configuration in /etc/network/interfaces file. If you need help simply use man interfaces command.
Uhm, but I think you need a basic config to use at home with WPA encryption… you don’t have time to read / search / study… that’s so strange!! 😀
So that’s it: edit /etc/network/interfaces (you need root privileges) and put this at the end of file.
#IW
# uncomment next row if you want your wlan active at startup
#auto wlan0
iface wlan0 inet dhcp
pre-up (echo 'Modprobing iwl4965') && /sbin/modprobe iwl4965
post-down (echo 'Removing iwl4965') && /sbin/modprobe -r iwl4965
wpa-ssid YOURNETNAMEAKASID
wpa-key_mgmt WPA-PSK
wpa-proto WPA
wpa-pairwise TKIP
wpa-group TKIP
wpa-psk "yourpassphrase"
wpa-driver wext
With this config you can easy bring up/down your wlan with ifup wlan0 or ifdown wlan0 as root user.
Note: in order to use wpa you need to install a package called wpasupplicant. Install it with apt-get install wpasupplicant as root user.
Have a nice day!
HP notebook dv2690el and linux and… WOW!!!
Hp dv2690el (dv2000 series) is my new laptop.
Microsoft Vista is too much slow for a pc like this… Who code Vista think to users or think to Hardware Productors? I can’t belive that a new machine equipped with centrino duo and 2gb ram may be slow like it may be with Vista… like a pentium II and XP four years ago…
So, my friend, I’m going on linux with my preferred distro: Debian. And I’m going like a rocket!!!
When I bought this notebook I thinked «I hope that linux works with it».
But now, with debain unstable and kernel 2.6.26-1-686 I think: «Wow!!! It’s completly ready to work after installation!!!». Webcam works without any configuration, also with Skype. alsaconf configure audiocard in no more than 30s, nvidia video card has native linux drivers directly from productor, wlan is active immediatly and without problems (see my dv2690el linux wireless how-to), touchpad it’s right, eth0 works without problems during installation (NETinst) and after, k3b burn CDs and DVDs whitout stop, special keys work immediatly with xmodmap and remote control too… simply wonderful!!!
You like linux and want a new notebook? dv2690el it’s a good choice!
To use special keys and remote control put these rows in a new file:
keycode 162 = XF86AudioPlay
keycode 164 = XF86AudioStop
keycode 144 = XF86AudioPrev
keycode 153 = XF86AudioNext
keycode 174 = XF86AudioLowerVolume
keycode 176 = XF86AudioRaiseVolume
keycode 160 = XF86AudioMute
Name this file .Xmodmap and put it in your home (~) directory. Reload X or type xmodmap ~/.Xmodmap.
Utilissimo: da oggi righe e colonne con Inkscape!
Con la nuova versione 0.46 è possibile creare tabelle in modo semplice e veloce. Read More…
Nuova versione di Inkscape, 0.46!
Sto finalmente provando la nuova versione 0.46 di Inkscape dopo aver aggiornato la mia Debian Unstable.
Stupendo il nuovo strumento `Ritocca Oggetti Scolpendoli o Ridipingendoli`.
Fa esattamente quello che si ripromette di fare! Vi permetterà di modificare i vostri oggetti come se fossero fatti di plastilina. Sei modalità sono infatti destinate alle “sculture” mentre altre due sono dedicate alle “tinteggiature”.
Il nuovo strumento `Disegna solido 3d` vi permetterà di realizzare con agilità nuovi disegni in falso 3d attraverso Inkscape.
La nuova selezione “multi-livello” vi renderà la vita più facile evitandovi di dover cercare oggetti saltellando tra i livelli, cosa che si rendeva indispensabile fino ad ora. Read More…
Estendere Ruby con C
Capita a volte di aver bisogno di estendere Ruby con codice C.
I motivi principali riguardano le performance dell’applicativo e la comodità garantita da un linguaggio di basso livello come C.
Altre motivazioni possono riguardare la necessità di utilizzare con Ruby una libreria C non disponibile in Ruby.
Nel mio caso ho trovato estremamente utile, se non del tutto necessario, utilizzare C per eseguire operazioni di compressione/decompressione con l’algoritmo di Huffman, in special modo sentivo particolarmente la mancanza dei comodi puntatori C.
Dopo una breve ricerca ho trovato un buon tutorial in lingua inglese su rubyinside.com.
Seguendo il tutorial potrete compilare la vostra libreria in C e creare un modulo da utilizzare per estendere una classe Ruby.
Per completezza, ho trovato anche altri metodi per ottenere risultati similari, tra i quali Ruby Inline, Swig e DL. A mio parere però, nessuno di questi metodi ha la linearità e la semplicità del metodo offerto da `How to create a Ruby extension in C in under 5 minutes` di Peter Cooper.
A breve creerò un tutorial per questa utile funzionalità .
SVILUPPO WEB – Linee Guida
Lo sviluppo di un Sito Web professionale deve seguire degli steps di lavoro che coinvolgono in prima persona diverse figure professionali.
Di seguito alcune Linee Guida utili alle Aziende che intendono mettere in Internet il proprio Sito Aziendale elaborato in collaborazione con Claudio Ancillotti e Alessandro Castagna.
Ruby on Rails & Compressed Prototype
Hello! Today I’m wandering about a compressed version of prototype to use in my brand new ruby on rails application.
Initialy I didn’t understand why rails doesn’t provide a compressed version of prototype but after some googling I’ve found some usefull answers.
Concept is simply clear.
Why use a compressed/packed version of prototype if we can provide it to clients throught gzip compression with best results? There isn’t a valid reason.
So we need to provide a gzip compressed version of prototype.
Nuovo sito per Gianfranco Gabaldo
Da oggi è online il nuovo sito ufficiale di Gianfranco Gabaldo.
Gianfranco Gabaldo si dedica da alcuni anni alla pittura con costanza e passione, realizzando opere ad olio che denotano equilibrio, gusto compositivo e cromatico, fantasia. Ciò si può intendere osservando la sobrietà d’impiego dei colori, improntati a gemme tra loro accordantisi, in gradazioni lievi e sofisticate, capaci di conferire alle singole pitture suggestione e armonia insieme.
Al più presto inseriremo le sue opere che vi consiglio di osservare con cura. I quadri sono veramente belli e giustificano sicuramente la visita ad uno degli eventi a cui partecipa l’artista.



