Skip to content

Instantly share code, notes, and snippets.

Ben Simpson bsimpson

Block or report user

Report or block bsimpson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bsimpson
bsimpson / gist:3019629
Created Jun 29, 2012
How to configure settings on an AR model
View gist:3019629

Intro

I have a Ruby model that needs to have a configuration option passed to it i.e. config/initializers/contact_import.rb define options so that:

ContactImport.import_mapping # => {'csv' => ..., 'csv_row' => ..., etc}

Option 1

Works in production environment, but not in development since classes reload

# config/initializers/contact_import.rb
@bsimpson
bsimpson / gist:2312761
Created Apr 5, 2012
Error message display
View gist:2312761

Introduction

Error messages are currently not handled in a consistent manner in Batchdeux's forms. I have modified the field_error_proc method which serves as a global way to change the behavior of form errors. By modifying this, I have given us the option to display errors in several ways:

Demo

git fetch
git checkout bls/23176299_data_validation_errors

Be sure to restart your webserver, as changes have been made to the config/ directory

@bsimpson
bsimpson / gist:2312760
Created Apr 5, 2012
Error message display
View gist:2312760
# Introduction
Error messages are currently not handled in a consistent manner in Batchdeux's forms. I have modified the `field_error_proc` method which serves as a global way to change the behavior of form errors. By modifying this, I have given us the option to display errors in several ways:
# Options
Options can be passed on an individual `:input` basis.
* `suppress_error` - Do not show any inline errors
* `error_before` - Show the label tag before the :input tag
You can’t perform that action at this time.