Holidays

Posted by kain Fri, 08 Aug 2008 08:43:00 GMT

Hi everyone,

sorry for not updating those pages during these days but I’m having a little holiday in Malta, I’ll be back blogging around 16/17 August.

my rails .gitignore 2

Posted by kain Thu, 24 Jul 2008 18:28:00 GMT

config/database.yml
*~
*.cache
*.log
*.pid
tmp/**/*
.DS\_Store
db/cstore/**
doc/api
doc/app
doc/plugins
coverage/*
db/*.sqlite3
*.tmproj
Capfile

usually I leave a config/database.yml.example, you can extend this list also to ignore the schema.rb.

edge rails should be able to recreate missing directory, because as you know git won’t follow empty directories, if that’s the case, just touch a .gitignore in tmp and log directories.

extra trick: to always ignore those files globally:

git config --global core.excludesfile /path/to/.gitignore

update:

suggested by schram:

doc/*.dot

to ignore railroad files

also for somebody is useful to have the sqlite production database versioned, so remove db/*.sqlite3.

another update:

ignored vim swap files

*.sw?

rails 2.2 i18n for the impatients

Posted by kain Thu, 24 Jul 2008 18:16:00 GMT

it’s all very straightforward and you can taste it already, grab a copy of edge rails and do this:

create a directory called "locale" in lib, and place two files, for example en-US.rb and it-IT.rb

Inside write:

# en-US.rb
I18n.store_translations 'en-US',
:yes => "yes",
:no => "no",
:action_show => "show",
:welcome => 'Welcome {{name}}!',
:inbox => ['1 message', '{{count}} messages']

as you can see we now have some symbol with our translation, do the same for it-IT.

it’s worth noticing the last two lines, {{name}} is a placeholder, let’s see how the things works.

open your ApplicationHelper and use this shortcut

  def t(*args)
    translate(*args)
  end

after that open a view and put this:

t(:welcome, :name => "kain") # sorry for the formatting

next: ApplicationController

before_filter :set_locale

  def set_locale
    default_locale = 'en-US'

    locale = params[:locale] || session[:locale] || (this_user.site_language if is_logged_in?) || default_locale
    session[:locale] = locale

    I18n.locale = locale
    I18n.populate do
      require "lib/locale/#{locale}.rb" # << WARNING: this is dangerous, change the method to load libs, maybe initializer
    end
  end

voilà, all done.

thanks to http://almosteffortless.com/2008/07/21/simple-localization-in-rails-22/

Troubles with ssh public key authentication

Posted by kain Sat, 19 Jul 2008 09:38:00 GMT

1) Always read your secure(.log) on your server

2) Do this in your server:

chmod go-w ~/
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

Chances are that you know what I’m talking about.

keep an eye into your plesk's qmail logs

Posted by kain Fri, 18 Jul 2008 11:02:00 GMT

Create a file check_maillog in /usr/local/sbin or where do you prefer, make it executable and wrote in it:

tail -f /usr/local/psa/var/log/maillog /var/spool/qscan/qmail-queue.log /var/spool/qscan/quarantine.log /var/log/clamav/clamd.log /var/log/clamav/freshclam.log

Remove every file that a .pkg provides

Posted by kain Fri, 18 Jul 2008 09:57:00 GMT

lsbom  -f -l -s /Library/Receipts/package_here.pkg/Contents/Archive.bom  | (cd /; sudo xargs rm)

CentOS 5 gem install mysql problems? 1

Posted by kain Thu, 17 Jul 2008 11:59:00 GMT

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... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

 Be sure to have mysql and mysql-devel packages, and install the gem with

gem install mysql -- --with-mysql-include=/usr/include/mysql --with-mysql-lib=/usr/lib/mysql

rails timestamped migrations optionals

Posted by kain Thu, 17 Jul 2008 02:00:00 GMT

 For some reason you don’t like timestamped migrations in rails?

Looking for a way to use integers again?

Grab off the latest rails edge and set:

 

config.active_record.timestamped_migrations = false

Passenger (aka mod_rails) PATH on Leopard 1

Posted by kain Sat, 12 Jul 2008 17:48:00 GMT

 Passenger uses a little subset of your PATH.

So if you have installed ruby, gem and misc binaries in other paths you cannot access them via your passenger rails application.

Here comes a solution, create an executable script ruby_with_env, I wrote it in my /usr/local/bin:

#!/bin/bash
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/graphviz/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/opt/local/bin:/usr/local/git/bin:/usr/local/git/bin/
:$PATH"
/usr/local/bin/ruby $*

 Now point the file to your PassengerRuby directive in your apache configuration file and restart.

no such file to load -- sqlite3/database 7

Posted by kain Sun, 06 Jul 2008 21:53:00 GMT

[kain@kain-osx:/usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.2]$ sudo find . -perm 0662 -exec chmod 664 {} \;

Update:Ruby Enterprise Edition is ahead of all: link

Older posts: 1 2