Skip to content

Instantly share code, notes, and snippets.

View carellen's full-sized avatar

Vladimir Saponko carellen

  • Warsaw, Poland
View GitHub Profile
@tyvsmith
tyvsmith / Setting.rb
Created June 5, 2011 20:42
Dynamic changes to schedule.rb for Whenever gem
class Setting < ActiveRecord::Base
validates_uniqueness_of :var
validates_presence_of :value
after_save :send_cron_later
#Setting.for(:display).set=(value)
def self.for(var)
find_or_create_by_var(var)
@rorlab
rorlab / environment.rb
Created October 4, 2012 10:51
Custom field_error_proc
# Custom field_error_proc
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
errors = Array(instance.error_message).join(', ')
if html_tag =~ /^<label/
if html_tag !~ /^<label(?:\s+.*)*(\s+alt="(?:checkbox|hidden)")(?:\s+.*)*\s*/
%(#{html_tag}).html_safe
else
%(#{html_tag}<span class="validation-error">&nbsp;#{errors}</span>).html_safe
end
else
@palkan
palkan / Gemfile
Last active April 25, 2024 14:23
RSpec profiling with RubyProf and StackProf
gem 'stackprof', require: false
gem 'ruby-prof', require: false