This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get '/:post_id' do | |
last_modification_of_post = Blog::Post[ params[:post_id], {:only => ['id', 'updated_on']} ] | |
last_modified( last_modification_of_post.updated_on ) if last_modification_of_post | |
@post = Blog::Post[ params[:post_id] ] | |
throw :halt, [404, erb(not_found) ] unless @post | |
erb :post | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rake task to extract texts from Ruby/ERb source in your application | |
# Scans patterns like "Hello World"[:hello_world] and dumps them into RAILS_ROOT/lang/new_language.yml | |
# TODO: Process incrementally, ie. dump newly added strings into existing localization files | |
require 'fileutils' | |
namespace :localize do | |
desc "Extract all texts prepared to be translated from Ruby source" | |
task :extract do | |
count, keys, out = 0, [], "# Localization dictionary for the 'Gibberish' plugin (#{RAILS_ROOT.split('/').last})\n\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# IN app/controllers/application.rb | |
require 'uri' | |
before_filter :set_language | |
# ... | |
# Set language by hostname (.com => 'en', .cz => 'cz') | |
def set_language |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_proper_localization_for_czech | |
falsify_today | |
hostname 'www.application.cz' | |
get :index | |
assert_tag :tag => 'h1', :content => 'Program Květen/Červen 2008' | |
assert_select '#topMenu a', :text => 'English' | |
assert_select '#headMenu strong', :text => 'Program' | |
assert_select '#program_item_2008-05-30 .day a', :text => 'pátek 30/05' | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_should_not_list_unpublished_projects | |
get :index | |
assert_equal 13, assigns(:projects).size | |
assert assigns(:projects).delete_if { |p| p.published? }.empty? | |
end | |
def test_should_show_404_when_trying_to_get_not_published_project | |
get :show, :id => 14 | |
assert assigns(:project) | |
assert_response :not_found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ClassMethods | |
# Declare in ActiveRecord or ActiveResource class with localized attributes | |
# You must include the module "manually" in your own classes (ie. put <tt>include HasLocalizedAttributes</tt> in your class) | |
# See README for example | |
def has_localized_atributes | |
include InstanceMethods unless included_modules.include?(InstanceMethods) | |
end | |
end | |
module InstanceMethods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dump of table translations | |
# ------------------------------------------------------------ | |
CREATE TABLE `translations` ( | |
`id` int(11) NOT NULL auto_increment, | |
`name` varchar(255) collate utf8_czech_ci default NULL, | |
`description` text collate utf8_czech_ci, | |
`lang` varchar(255) collate utf8_czech_ci default NULL, | |
`reference_id` int(11) default NULL, | |
`created_at` datetime default NULL, | |
`updated_at` datetime default NULL, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# artist.rb | |
class Artist < ActiveRecord::Base | |
has_many :works | |
has_many :compositions, :through => :works | |
end | |
# composition.rb | |
class Composition < ActiveRecord::Base | |
has_many :works | |
has_many :artists, :through => :works |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From eb62ad214483022e5332da258f04c6480bce86cb Mon Sep 17 00:00:00 2001 | |
From: Karel Minarik <karmi@karmi.cz> | |
Date: Thu, 14 Aug 2008 18:46:33 +0200 | |
Subject: [PATCH] Added expire_fragment_by_glob() method to ActionController::Caching::Fragments | |
--- | |
.../lib/action_controller/caching/fragments.rb | 14 ++++++++++++++ | |
actionpack/test/controller/caching_test.rb | 19 +++++++++++++++++++ | |
2 files changed, 33 insertions(+), 0 deletions(-) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vim .gitignore | |
.DS_Store | |
*/.DS_Store | |
log/*.log | |
tmp/**/* | |
config/database.yml | |
config/deploy.rb | |
db/*.sqlite3 | |
doc/app/ | |
public/uploads/* |
OlderNewer