Tag Archive | rails

ruby on rails on nokia N900

Yes, we can! ruby on rails works well on nokia n900.
Install ruby from maemo repository (dev).
Download and install rubygems (use –no-rdoc and –no-ri).

Rubygems creates only /usr/bin/gem1.8 so you should create a soft link like this: ln -s /usr/bin/gem1.8 /usr/bin/gem

Type gem install rails -V and wait.

Now you are ready to start your rails app on nokia n900!
Just run ruby script/server in your project folder. To create a project folder use rails my_app as usual.

Your server may not start if you miss libopenssl-ruby. In this case you get an error about net/https: apt-get install libopenssl-ruby.

rails date validation, rails validate date for date_select

Ok, you are in right place if you need to validate a date from date_select helper.
Expecially if your problem is an invalid date like ’31/02/2009′  that becomes ’02/03/2009′ on rails!
If you don’t want to waste your time read here and don’t go immediatly to rails date validation plugin .

validates_timeliness plugin introduces a lot of great features to validate a date but its documentation is not so cool (this is my absolutely wrong opinion). You have to read it completly or take a look here about 3 important points:

  • I18n
    if you don’t use :en locale you have to implement validates_timeliness default translation in your translations file (for ex. config/locales/it.yml) or you will waste your time to debug stupid exceptions. Default plugin translation file can be found in vendor/plugin/validates_timeliness/lib/validates_timeliness/locale after installation;
  • Validate invalid date (like 31/02/2009 becomes 02/03/09) from select helpers
    You need to know that validates_timeliness doesn’t fix this problem automatically as you expect!
    You have to manually enable validates_timeliness workaround if you need to validate invalid date on rails.
    Put ” ValidatesTimeliness.enable_datetime_select_extension! ” your environment.rb (EOF) to enable validate_timeliness workaround and catch bad dates.
    Note: Patch to ticket #10556 introduced this problem: rails accepts invalid dates from input (instantiate Time object and convert it back to a date).  This problem generates a lot of confusion, checks on controllers, horrible workarounds and so on… A valid reason seems to exist! But WTF!!! People in panic and code with consistency problems…

Any other information (and download) can be find on validates_timeliness at github.

Have a nice day!

 

validates_timeliness

lighttpd, fcgi, rails and child exited with status 9, 1, 2, 3 or X

Ok, these errors are not good. They didn’t tell much about what happended.
But you can’t do as I did. Don’t wander on the dark side of the system…
Just try to execute your FCGI as your lighttpd did.
Find your lighttpd user in lighttpd configuration file (debian: /etc/lighttpd/lighttpd.conf).
On my configuration I see:
server.username  = “www-data”

so…

$ su
# cd /my_rails_root/public
# sudo -u www-data ./dispatch.fcgi

Read what’s happen and solve.
That’s all!

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.

Read More…

Rails è veloce, comodo, ma sarà anche sicuro?

Rails è sicuro? In quanti se lo saranno chiesto fino ad ora. Sicuramente la risposta è sì, ma come in ogni programma tutto dipende dallo sviluppatore. Php ad esempio di per se non implementa alcuna misura di sicurezza, ogni implementazione, dalla più piccola alla più complessa è richiesta direttamente all’utente.
Questo aspetto può comportare gravi rischi per chi non sa quello che fa, ma aiuta il professionista a concentrarsi a fondo sui dettagli, senza trascurare nulla.

Rails invece permette di creare sistemi di autenticazione e gestione dei permessi in tempi rapidissimi, con una velocità degna di una formula 1. Ma qual è lo scotto?

Read More…