Skip to content

Instantly share code, notes, and snippets.

View cyrille's full-sized avatar

Cyrille Stepanyk cyrille

  • Rapidonweb
  • Paris
View GitHub Profile
@NickClark
NickClark / Error
Created May 13, 2011 01:09
Deployment Gemfile.lock woes
You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.
You have deleted from the Gemfile:
* guard-pow
* rb-fsevent
@ryanb
ryanb / rails_3_1_rc4_changes.md
Created May 6, 2011 01:10
The Changelogs for Rails 3.1 Beta 1

Railties 3.1 RC4

  • The new rake task assets:clean removes precompiled assets. [fxn]

  • Application and plugin generation run bundle install unless --skip-gemfile or --skip-bundle. [fxn]

  • Fixed database tasks for jdbc* adapters #jruby [Rashmi Yadav]

  • Template generation for jdbcpostgresql #jruby [Vishnu Atrai]

# Sends the translated version of a given object attribute.
#
# Example:
# Given that locale is :fr
# t_attribute(@post, :description)
# will return @post.description_fr or fallback to @post.description.
def t_attribute(object, attribute)
localized_attribute = "#{attribute}_#{I18n.locale}"
object.respond_to?(localized_attribute) ? object.send(localized_attribute) : object.send(attribute)
end
@clemens
clemens / product.rb
Created April 17, 2011 21:27
Faster Sphinx facets
class Product < ActiveRecord::Base
define_index do
# rest of the index ...
has merchant_id
has merchant.company, :as => :merchant_name, :type => :string
has brand_id, :type => :integer
has brand.name, :as => :brand_name, :type => :string
@cyrille
cyrille / Routes URLs
Created March 13, 2011 09:06
Rails one-liner to get URLs from rake routes
rake routes | sed -e "1d" -e "s,^[^/]*,,g" | awk '{print $1}' | uniq | sort
Source: http://trevmex.com/post/3822870892/rails-one-liner-to-get-urls-from-rake-routes
# Pluralize helper for French language.
#
# Because French pluralization has special rules :
# Example :
# pluralize(0, "degré") # => "0 degré"
# pluralize(1, "degré") # => "1 degré"
# pluralize(2, "degré") # => "2 degrés"
# pluralize(0.5, "degré") # => "0.5 degré"
# pluralize(1.9, "degré") # => "1.9 degré"
# pluralize(-1.9, "degré") # => "-1.9 degré"