Deprecated: Assigning the return value of new by reference is deprecated in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/cache.php on line 99

Deprecated: Assigning the return value of new by reference is deprecated in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/theme.php on line 576
Dirk.Net » Blog Archive » Sorted and Translated ActiveRecord Model with Globalize2 and Ruby Magic

Warning: mktime() [function.mktime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/functions.php on line 19

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/functions.php on line 28

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/functions.php on line 30

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/functions.php on line 32

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/functions.php on line 33

Warning: mktime() [function.mktime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/functions.php on line 19

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/functions.php on line 28

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/functions.php on line 30

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/functions.php on line 32

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/functions.php on line 33

Sorted and Translated ActiveRecord Model with Globalize2 and Ruby Magic

Uncategorized Add comments

Warning: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/link-template.php on line 73

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-includes/link-template.php on line 98

Deprecated: Function split() is deprecated in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-content/plugins/adsense-manager/adsense-manager.php on line 138

Deprecated: Function split() is deprecated in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-content/plugins/adsense-manager/adsense-manager.php on line 138

Deprecated: Function split() is deprecated in /home/deploy/wordpress_blogs/www/dirknet/wordpress/wp-content/plugins/adsense-manager/adsense-manager.php on line 138

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.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in