You are currently browsing the tag archive for the 'Rails' tag.
Again I read an article about background processing that generates many different jobs which all do the same: call method a on b with parameter z. At the moment we are using one GenericJob to handle all those cases.
It serializes ActiveRecord objects to a string representation, so that they do not get submittet as instance(often too large or deserialisation problems), if you do not need this feature, :send_later could be a good option for starting with generic jobs.
Usage
Install
Since my old Ubuntu lived a long live and saw numerous hacks, I chose to reinstall from scratch, here are the steps I took:
- install dotfiles
- Skype
- Multi-clipboard: sudo apt-get install glipper
- Application laucher: sudo apt-get install gnome-do + enable skype plugin
- Ruby enterprise
- Rubymine + Desktop icon+ Meta key for Rubymine
- Mysql: sudo apt-get install mysql-server mysql-client libmysql-ruby
- Apache: sudo apt-get install apache2 apache2-mpm-prefork apache2-prefork-dev
- Passenger
- SSL for apache/passenger
- gem sources -a http://gems.github.com
- gems…
- Java: sudo apt-get install sun-java6-jre
- Git: sudo apt-get install git-core
No more hacks, everything works, very fast startup (~10s), faster graphics (for intel chips)
Making a certificate
sudo mkdir /etc/apache2/ssl sudo /usr/sbin/make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem sudo nano /etc/apache2/sites-available/default-ssl #deactivete other crt/key files (snakeoil) SSLCertificateFile /etc/apache2/ssl/apache.pem sudo a2ensite default-ssl sudo a2enmod ssl sudo /etc/init.d/apache2 restart
Configure passenger
<VirtualHost *:80> ServerAlias *.something.com RailsEnv development DocumentRoot /apps/something/public </VirtualHost> <VirtualHost *:443> SSLEngine on SSLCertificateFile /etc/apache2/ssl/apache.pem ServerAlias *.something.com RailsEnv development DocumentRoot /apps/something/public </VirtualHost>
host
# descriptive raise
# normale: raise 1 == TypeError: exception class/object expected
# now: raise 1 == RuntimeError: 1
class Object
def raise_with_helpfulness(*args)
raise_without_helpfulness(*args)
rescue TypeError => e
raise_without_helpfulness args.first.inspect if e.to_s == 'exception class/object expected'
raise e
end
alias_method_chain :raise, :helpfulness
If you noticed spork startup getting slower when switching to Rails 2.3, your not alone
- Views are eager loaded
- app/ is eager loaded (when config.cache_classes is on)
Without hack: 18s startup
With hack: 2s startup
Try it
#spec/spec_helper.rb
begin
require 'spork/app_framework/rails'
module Spork::AppFramework::Rails::NinjaPatcher
# views are preloaded spork must be restarted for view changes
def delay_eager_view_loading
puts "removed because i am too slow..."
end
# do not preload application files
# alternatively urn off config.cache_classes
def delay_app_preload
::Rails::Initializer.send(:define_method, :load_application_classes) do
end
end
end
rescue
end
Spork.prefork do
...

