Skip to content

Instantly share code, notes, and snippets.

View brunto's full-sized avatar

Bruno Perles brunto

View GitHub Profile
NoMethodError in RailsAdmin::MainController#dashboard
undefined method `limit' for 0.0.5:Class
/home/brunto/.rvm/gems/ruby-1.9.3-p125@rails32x/bundler/gems/rails_admin-220745475c18/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb:47:in `latest'
/home/brunto/.rvm/gems/ruby-1.9.3-p125@rails32x/bundler/gems/rails_admin-220745475c18/lib/rails_admin/config/actions/dashboard.rb:17:in `block (2 levels) in <class:Dashboard>'
(eval):8:in `instance_eval'
(eval):8:in `dashboard'
actionpack (3.2.6) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.2.6) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.6) lib/action_controller/metal/rendering.rb:10:in `process_action'
@brunto
brunto / gist:3089435
Created July 11, 2012 10:11
Rails3 locale
In my application.rb :
config.i18n.available_locales = [:fr, :en, :nl, :es]
My routes :
scope "(:locale)" do
root :to => "home#index"
devise_for :users, :controllers => {:registrations => 'registrations'}
get '/home/test' => 'home#test', :as => 'home_test'
@brunto
brunto / gist:3378398
Created August 17, 2012 12:19
Ruby sort_by
pdf_info = {
"John"=>{"format_b"=>{"file_z"=>{:quantity=>1, :free=>false}, "file_f"=>{:quantity=>1, :free=>true}}},
"Brunto"=>{"format_a"=>{"file_w"=>{:quantity=>1, :free=>false}, "file_g"=>{:quantity=>1, :free=>true}}}
}
new_pdf_info = {}
pdf_info = pdf_info.sort_by {|k| k}
pdf_info.each do |customer, format_orders|
@brunto
brunto / watermark.rb
Created October 29, 2012 17:01 — forked from laurynas/watermark.rb
Paperclip Watermark processor
# Based on
# https://github.com/ng/paperclip-watermarking-app/blob/master/lib/paperclip_processors/watermark.rb
# Modified by Laurynas Butkus
module Paperclip
class Watermark < Processor
# Handles watermarking of images that are uploaded.
attr_accessor :format, :whiny, :watermark_path, :position
def initialize file, options = {}, attachment = nil
#app/inputs/collection_check_boxes_input.rb
class CollectionCheckBoxesInput < SimpleForm::Inputs::CollectionCheckBoxesInput
def item_wrapper_class
"checkbox-inline"
end
end
struct Daterange
def self.adapter
Lucky
end
module Lucky
alias ColumnType = UInt8
include Avram::Type
def parse(value : UInt8)