Skip to content

Instantly share code, notes, and snippets.

View achempion's full-sized avatar
✍️
Writing software

Boris Kuznetsov achempion

✍️
Writing software
View GitHub Profile
@achempion
achempion / internalization_helper.rb
Created October 22, 2012 20:00
simple db localization
module InternalizationHelper
# let's imagine that some methods defined in your model like 'title_en' and 'title_ru' for different locales
# helper will create 'title' method depending on current I18n.locale
# Model.rb
# extend InternalizationHelper
# define_translations_for 'title', 'description', ...
def define_translations_for *methods
methods.each do |method_name|
@achempion
achempion / content_tag.js
Created October 14, 2012 14:15
Простой метод, позволяет создавать теги как с помощью рельсового метода `content_tag`
var content_tag;
content_tag = function(tag, content, params){
var tag, content, params, res;
var insert_params = '';
for(var key in params){
insert_params += ' '+key+'='+'"'+params[key]+'"';
}
if(content){
res = '<'+tag+insert_params+'>'+content+'</'+tag+'>';
} else {