View semantic_error_messages_for.rb
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
# Semantic error messages for is used with formtastic and it will generate error messages for attributes you | |
# are passing including base. | |
# You can use it like this: | |
# - semantic_form_for (...) | |
# = semantic_error_messages_for @model, :attribute, :another_one | |
def semantic_error_messages_for(object, *methods) | |
full_errors = methods.inject([]) do |array, method| | |
attribute = object.class.human_attribute_name(method) | |
errors = Array(object.errors.on(method)).to_sentence |
View sphinx.rb
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
# encoding: ASCII-8BIT | |
require 'test_helper' | |
class SearchTest < ActiveSupport::TestCase | |
self.use_transactional_fixtures = false | |
def self.startup | |
start_sphinx do | |
us_country = Factory(:us_country) |
View i18n_ascii_8bit.rb
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
# config/initializers/i18n_ascii_8bit.rb | |
module I18n | |
module Backend | |
class Simple | |
def load_yml(filename) | |
traverse(YAML::load(IO.read(filename))) { |o| o.force_encoding(Encoding::ASCII_8BIT) if o.respond_to?(:force_encoding) } | |
end | |
def traverse(object, &block) |
View gist:367696
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
/home/slugs/143697_fd755c5_8ed7/mnt/.bundle/gems/gems/bundler-0.9.19/lib/bundler/environment.rb:83:in `initialize': Read-only file system - /disk1/home/slugs/143697_fd755c5_8ed7/mnt/.bundle/environment.rb - Heroku has a read-only filesystem. See http://docs.heroku.com/constraints#read-only-filesystem (Errno::EROFS) | |
from /home/slugs/143697_fd755c5_8ed7/mnt/.bundle/gems/gems/bundler-0.9.19/lib/bundler/environment.rb:83:in `open' | |
from /home/slugs/143697_fd755c5_8ed7/mnt/.bundle/gems/gems/bundler-0.9.19/lib/bundler/environment.rb:83:in `write_rb_lock' | |
from /home/slugs/143697_fd755c5_8ed7/mnt/.bundle/gems/gems/bundler-0.9.19/lib/bundler/runtime.rb:10:in `initialize' | |
from /home/slugs/143697_fd755c5_8ed7/mnt/.bundle/gems/gems/bundler-0.9.19/lib/bundler.rb:102:in `new' | |
from /home/slugs/143697_fd755c5_8ed7/mnt/.bundle/gems/gems/bundler-0.9.19/lib/bundler.rb:102:in `runtime' | |
from /home/slugs/143697_fd755c5_8ed7/mnt/.bundle/gems/gems/bundler-0.9.19/lib/bundler.rb:96:in `load' | |
from /home/slugs/143697_fd755c5_8ed7 |
View gist:386312
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
/home/wojtek/Ruby/libre/config/initializers/haml.rb:1:in `<top (required)>': uninitialized constant Haml::Template (NameError) | |
from /home/wojtek/.rvm/gems/ruby-1.9.1-p378/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/railties/lib/rails/engine.rb:199:in `block (2 levels) in <class:Engine>' | |
from /home/wojtek/.rvm/gems/ruby-1.9.1-p378/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/railties/lib/rails/engine.rb:198:in `each' | |
from /home/wojtek/.rvm/gems/ruby-1.9.1-p378/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/railties/lib/rails/engine.rb:198:in `block in <class:Engine>' | |
from /home/wojtek/.rvm/gems/ruby-1.9.1-p378/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/railties/lib/rails/initializable.rb:25:in `instance_exec' | |
from /home/wojtek/.rvm/gems/ruby-1.9.1-p378/bundler/gems/rails-16a5e918a06649ffac24fd5873b875daf66212ad-master/railties/lib/rails/initializable.rb:25:in `run' | |
from /home/wojtek/.rvm/gems/ruby-1.9.1-p378/bundler/ |
View gist:498149
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
# rvm is installed into /usr/local/rvm | |
# all users added to group rvm can manage rubies | |
package "curl" | |
package "libreadline5-dev" # for ruby ree | |
template "/etc/gemrc" do | |
source "gemrc.erb" | |
end |
View gist:500586
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
script "Install rvm" do | |
interpreter "bash" | |
user node[:app][:name] | |
code <<-EOH | |
export | |
rvm_path="${rvm_path:-$HOME/.rvm}" | |
mkdir -p $rvm_path/src/ | |
builtin cd $rvm_path/src | |
rm -rf ./rvm/ | |
git clone --depth 1 git://github.com/wayneeseguin/rvm.git |
View gist:650985
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
# attributes/default.rb | |
default[:my_attribute] = false | |
# on some machine: | |
chef-client -j example.json | |
# example.json | |
{"run_list": "recipe[example]", "my_attribute": true} | |
value used in recipe is now true |
View chef.rb
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
# hack for the chef - we cannot read file in http_request resource | |
ruby_block "Set attributes for http request for #{database[:name]} #{database[:kind]}" do | |
block do | |
request = resources(:http_request => "Create backup record for #{database[:name]} #{database[:kind]}") | |
request.message({:backup => {:filename => compressed_file_name, :kind => database[:kind], :size => File.size(compressed_file_path)}}) | |
end | |
end | |
http_request "Create backup record for #{database[:name]} #{database[:kind]}" do | |
url "http://some-url/backups" |
View gist:822127
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 respond_with(*resources, &block) | |
raise "In order to use respond_with, first you need to declare the formats your " << | |
"controller responds to in the class level" if self.class.mimes_for_respond_to.empty? | |
if response = retrieve_response_from_mimes(&block) | |
options = resources.size == 1 ? {} : resources.extract_options! | |
resources = resources.size == 1 ? Array.wrap(resources.first) : resources | |
options.merge!(:default_response => response) | |
(options.delete(:responder) || self.class.responder).call(self, resources, options) | |
end |
OlderNewer