Skip to content

Instantly share code, notes, and snippets.

@mrship
mrship / gist:3858842
Created October 9, 2012 13:33
Stack trace from Client Side Validation error
/Users/andy/.rvm/gems/ruby-1.9.2-p290@mfl/bundler/gems/client_side_validations-5665bf4899f1/lib/client_side_validations/active_model.rb:138:in `uniqueness_validations_allowed_or_not_applicable?'
/Users/andy/.rvm/gems/ruby-1.9.2-p290@mfl/bundler/gems/client_side_validations-5665bf4899f1/lib/client_side_validations/active_model.rb:71:in `can_use_for_client_side_validation?'
/Users/andy/.rvm/gems/ruby-1.9.2-p290@mfl/bundler/gems/client_side_validations-5665bf4899f1/lib/client_side_validations/active_model.rb:31:in `block (2 levels) in client_side_validation_hash'
/Users/andy/.rvm/gems/ruby-1.9.2-p290@mfl/bundler/gems/client_side_validations-5665bf4899f1/lib/client_side_validations/active_model.rb:30:in `each'
/Users/andy/.rvm/gems/ruby-1.9.2-p290@mfl/bundler/gems/client_side_validations-5665bf4899f1/lib/client_side_validations/active_model.rb:30:in `inject'
/Users/andy/.rvm/gems/ruby-1.9.2-p290@mfl/bundler/gems/client_side_validations-5665bf4899f1/lib/client_side_validations/active_model.rb:30:in `block in clien

OK, here's a simple example for entering a height as either feet and inches or as cm.

.height-in-feet
  = f.input :height_in_feet, required: true, input_html: { :"data-mfl-hint-target" => "div.height-details", :"data-mfl-validate-proxy" => "input#consumers_details_health_height", maxlength: 1 }
.height-in-inches
  = f.input :height_in_inches_after_feet, required: true, input_html: { :"data-mfl-hint-target" => "div.height-details", :"data-mfl-validate-proxy" => "input#consumers_details_health_height", maxlength: 2 }
.height-in-centimetres
  = f.input :height_in_centimetres, required: true, input_html: { :"data-mfl-hint-target" => "div.height-details", :"data-mfl-validate-proxy" => "input#consumers_details_health_height", maxlength: 3 }
.hidden
@mrship
mrship / gist:3370258
Created August 16, 2012 13:51
Simple form hack
if Rails.env.staging?
module SimpleForm
module Inputs
class Base
def translate(namespace, default='')
model_names = lookup_model_names.dup
lookups = []
while !model_names.empty?
joined_model_names = model_names.join(".")
@mrship
mrship / gist:2404790
Created April 17, 2012 09:13
SimpleForm hacks for Phrase
# original SimpleForm code (lib/simple_form/inputs/base.rb:142)
def translate(namespace, default='')
model_names = lookup_model_names.dup
lookups = []
while !model_names.empty?
joined_model_names = model_names.join(".")
model_names.shift
@mrship
mrship / rspec_test_within_a_block.rb
Created January 24, 2012 11:01
RSpec testing within a block
module PdfRenderer
describe Header do
let(:pdf) { mock(Prawn::Document) }
subject { Header.new(pdf) }
describe "#render" do
it "draws the header" do
pdf.should_receive(:repeat).with(:all) do
pdf.should_receive(:move_down) # this fails
end
@mrship
mrship / gist:1183134
Created August 31, 2011 09:11
XML error from JPEGMini
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>AC15B5DF72BA4CE6</RequestId>
<HostId>
POdz8uifrkuLWh7oA7cM+3GEURcPyItETksNEWt3aPVDcqF4CD4NcmsfPaToLeAg
</HostId>
</Error>
@mrship
mrship / gist:974068
Created May 16, 2011 07:55
Log crash for Heroku w/ NewRelic
2011-05-16T07:52:42+00:00 app[web.1]: /app/vendor/plugins/rpm/lib/new_relic/control/frameworks/rails.rb:29:in `install_episodes': undefined method `episodes_enabled?' for Control[rails3]:NewRelic::Control::Frameworks::Rails3 (NoMethodError)
2011-05-16T07:52:42+00:00 app[web.1]: from /app/vendor/plugins/rpm/lib/new_relic/control/frameworks/rails.rb:24:in `init_config'
2011-05-16T07:52:42+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/newrelic_rpm-3.0.0/lib/new_relic/control/instance_methods.rb:60:in `init_plugin'
2011-05-16T07:52:42+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/newrelic_rpm-3.0.0/lib/newrelic_rpm.rb:36:in `block in <class:Railtie>'
2011-05-16T07:52:42+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.7/lib/rails/initializable.rb:25:in `instance_exec'
2011-05-16T07:52:42+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9.1/gems/railties-3.0.7/lib/rails/initializable.rb:25:in `run'
2011-05-16T07:52:42+00:00 app[web.1]: from /app/.bundle/gems/ruby/1.9
module Rack
class EnsureSsl
def initialize(app)
@app = app
end
def call(env)
ssl_request?(env) ? @app.call(env) : ssl_redirect(env)
end
<?xml version='1.0' encoding='utf-8' ?>
<notice version='2.0.0'>
<api-key>bb2ccbb9fb37971f5b1d8f2810d81064</api-key>
<notifier>
<name>Merb::HoptoadNotifier</name>
<version>1.0.10</version>
<url>http://github.com/toolmantim/toadhopper</url>
</notifier>
<error>
<class>NoMethodError</class>
!!! Strict
%html{ html_attrs("en_gb") }
%head
%title
Times Too
%meta{ :content => "text/html; charset=utf-8", "http-equiv" => "content-type" }/
%script{ :type => "text/javascript", :src => "http://localhost/~andy/javascripts/dojo/dojo.js.uncompressed.js", :djConfig => "parseOnLoad: true" }
:javascript
dojo.registerModulePath("dijit", "http://localhost/~andy/javascripts/dijit")
dojo.registerModulePath("dojox", "http://localhost/~andy/javascripts/dojox")