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 create(article) | |
@article = Article.new(article) | |
if @article.save | |
eager_cache :show, :uri => url(:article, @article) | |
redirect resource(@article), :message => {:notice => "Article was successfully created"} | |
else | |
#.... | |
end | |
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
default_scope :select => (column_names - %w(blob)).join(',') | |
def self.find_with_blob(*args) | |
with_exclusive_scope{find(*args)} | |
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 set_locale | |
I18n.locale = @original_locale = fallback_locale(I18n.locale) | |
if request.host =~ /^([\w-]+)\.#{HOST.split(':')[0]}/i | |
I18n.locale = fallback_locale($1) | |
end | |
end | |
private | |
def fallback_locale(locale) | |
locale = locale.to_s |
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
#!/bin/sh | |
rm -rf jruby-core.jar | |
rm -rf ruby-stdlib.jar | |
rm -rf tmp_unpack | |
mkdir tmp_unpack | |
cd tmp_unpack | |
jar xf ../jruby-complete.jar | |
cd .. | |
mkdir jruby-core |
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
if File.directory?(gems_dir = File.join(root, "gems")) && !$BUNDLE | |
$BUNDLE = true; Gem.clear_paths; Gem.path.unshift(gems_dir) | |
# Warn if local merb-core is available but not loaded. | |
if File.expand_path($0).index(root) != 0 && | |
(local_mc = Dir[File.join(gems_dir, "specifications", "merb-core-*.gemspec")].last) | |
puts "Warning: please use bin/#{File.basename($0)} to load #{File.basename(local_mc, ".gemspec")} from ./gems" end | |
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
if File.directory?(gems_dir = File.join(root, "gems")) && !$BUNDLE | |
$BUNDLE = true; Gem.clear_paths; Gem.path.unshift(gems_dir) | |
# Warn if local merb-core is available but not loaded. | |
if File.expand_path($0).index(root) != 0 && | |
(local_mc = Dir[File.join(gems_dir, "specifications", "merb-core-*.gemspec")].last) | |
puts "Warning: please use bin/#{File.basename($0)} to load #{File.basename(local_mc, ".gemspec")} from ./gems" end | |
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
module DataMapper | |
module Types | |
class Currency < DataMapper::Type | |
class BigDecimal255 < ::BigDecimal | |
limit 255 | |
end | |
primitive String | |
size 255 |
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
// | |
// RootViewController.m | |
// Icons | |
// | |
// Created by takiuchi on 09/02/22. | |
// Copyright s21g LLC 2009. All rights reserved. | |
// | |
#import "RootViewController.h" | |
#import "IconsAppDelegate.h" |
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 DataMapper | |
module Adapters | |
class DataObjectsAdapter < AbstractAdapter | |
module SQL | |
private | |
alias :property_to_column_name_org :property_to_column_name | |
def property_to_column_name(repository, property, *args) | |
result = property_to_column_name_org(repository, property, *args) | |
if property.respond_to?(:name) && property.name == :"count(*)" | |
result.gsub!(/^"|"$/, '') |
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 Errorifier | |
def error_messages_for(obj, error_class, build_li, header, before) | |
obj ||= @obj | |
return "" unless obj.respond_to?(:errors) | |
sequel = !obj.errors.respond_to?(:each) | |
errors = sequel ? obj.errors.full_messages : obj.errors | |
return "" if errors.empty? | |
header_message = header % [errors.size, errors.size == 1 ? "" : "s"] | |
markup = %Q{<div class='#{error_class}'>#{header_message}<ul>} |