Apr 24
If you get errors such as
fatal: Out of memory, malloc failed
error: pack-objects died with strange error
error: failed to push some refs to ‘git@myserver.com:foo.git’
when running
git push
first, upgrade git to the latest version on both ends, then check if
git repack
still works. If not, you might have a local issue.
If repack still works, your remote server (the server you push to) might actually run out of memory, which can easily happen with for example smallish VPS slices. So, just increase your swap file as Linus suggests, like this and it might start working again. Hope it helps.
Apr 06
This code returns all records of your model sorted by translated field name when using Globalize2 :
#app/models/widget.rb
def self.all_sorted
Widget.find(:all, :joins => :globalize_translations,
:conditions => ['locale = ?', I18n.locale]).sort_by(&:name)
end
As outlined it this post, :joins => :globalize_translations is mandatory. The unary ampersand operator converts a Proc to a block, so in this case sort_by(&:name) is “shorthand” for
sort {|x,y| x.name <=> y.name}
Ruby sometimes feels like assembling a Swiss watch in code, where other languages feel like fixing an old car.
Apr 05
If you get
Loading development environment (Rails 2.3.2)
/usr/local/lib/ruby/1.8/irb/completion.rb:10:in `require’: no such file to load — readline (LoadError)
from /usr/local/lib/ruby/1.8/irb/completion.rb:10
from /usr/local/lib/ruby/1.8/irb/init.rb:252:in `require’
from /usr/local/lib/ruby/1.8/irb/init.rb:252:in `load_modules’
from /usr/local/lib/ruby/1.8/irb/init.rb:250:in `each’
from /usr/local/lib/ruby/1.8/irb/init.rb:250:in `load_modules’
from /usr/local/lib/ruby/1.8/irb/init.rb:21:in `setup’
from /usr/local/lib/ruby/1.8/irb.rb:54:in `start’
from /usr/local/bin/irb:13
when running script/console, you might be missing some libraries after you’ve installed Ruby from source. So you might try (Ubuntu, Debian):
sudo apt-get install libncurses5-dev
sudo apt-get install libreadline5-dev
Then cd to the folder with your unpacked Ruby sources, subfolder ext/readline:
cd /usr/src/ruby-1.8.7-p72/ext/readline
ruby extconf.rb
make
sudo make install
There is no need to recompile Ruby. If you get any of these:
checking for tgetnum() in -lncurses… no
checking for tgetnum() in -ltermcap… no
checking for tgetnum() in -lcurses… no
checking for readline/readline.h… no
checking for editline/readline.h… no
you’re still missing libraries so re-check if the apt-get commands above completed without errors. Hope it helps.
Recent Comments