miércoles, 29 de abril de 2009

Flash Messages, System Messages, Ruby on Rails, by style, debug and test

controller:

flash[:notice] = "Correct things."
flash[:error] = "Alert things."
flash[:debug] = "Simple debug."


views/layouts:

<%- flash.each do |name, msg| -%>
<%= content_tag :div, msg, :id => "flash_#{name}" %>
<%- end -%>


css out of dev, in test, this can help you in both environments:

#debug{
display:none;
}

domingo, 26 de abril de 2009

ruby on rails i18n

An approach:

$script/plugin install git://github.com/svenfuchs/rails-i18n.git

$cp config/locales/en.yml config/locales/es-ar.yml

config/environment.rb

config.time_zone = 'Buenos Aires'
config.i18n.default_locale = :"es-ar"


app/views/payment_operation/show.html.erb

<%= t('views.payment.show_title', :count => @foo.size, :bar => @foo.name) %>


config/locales/es-ar.yml

es-ar:
views:
payment:
show_title:
zero: "Mostrando operación de pago y {{bar}}."
one: "Mostrando operación de pago y {{bar}}."
many: "Mostrando operación de pago y {{bar}}."

martes, 21 de abril de 2009

Survive in php.. a logger method.


function logger($msg){
if(!isset($GLOBALS['logger'])){
$GLOBALS['logger'] = fopen("/var/www/apps/logs/dev.log","a");
}
fwrite($GLOBALS['logger'],"$msg\n");
}

function request($id = ''){
logger("dir/file.php::request(id[".$id."])");
...
}

miércoles, 15 de abril de 2009

Conceptual views and Implementation Details.

FSM. Finite State Machine. This is real.

http://blog.objectmentor.com/articles/2008/11/27/the-truth-about-bdd

Languages, are implementation details?

http://blog.objectmentor.com/articles/2009/01/15/adopting-new-jvm-languages-in-the-enterprise